Bucky: C# Video Tutorial Is Too Confusing

+3 Cardinal Coog · June 27, 2015
Bucky:

I understand that someone named, "Adam" did the C# videos. Most of the videos are done pretty well; however, (IMHO) video #20 on constructors is very confusing. 

Could you please remake that video and describe constructors more clearly? I'd prefer you remade all the C# videos; but I know you're too busy.
Anyway, listening to those videos makes me wonder if  "Adam" has been smoking something other than cigarettes... ;)

Post a Reply

Replies

Oldest  Newest  Rating
+1 Kuroodo Ditory · July 1, 2015
(I mainly use Java, so sorry if I confuse some wording)

Constructors are a way to set up/construct a class and get it ready to do it's thing.

Let's say you want to make a bank account. To make a bank account you need to give the bank information that will be stored to your account. Once the bank has that information, your account is created and the information is stored on your account.

That is pretty much how constructors work.

They are optional and you don't always have to make one. They are also called as soon as you create a new object for a class.
MyClass myObject = new MyClass();. That code (specifically the new MyClass() part) calls the constructor of that class.


You can also have multiple constructors for one class. This is useful for when you create different kinds of objects for one class. Let's say you have a game and want to create multiples characters, some with animations and some without. You have one constructor that take in all data needed, including animations. Then you have another constructor that does the same thing but does not take in animations.


Here is an example of a constructor:

public class MyClass{

private MathClass myCalculator;

private int x;

// Constructor
public MyClass(){
myCalculator = new MathClass();

x = 10;
}

public void compute(){
myCalculator.square(x);
}


}


If we deleted the constructor and then called the method compute, we would get a null pointer exception, as well as x not having a value. But with the constructor, it sets everything up, and then we can call the compute method no problem.


Another example:


public class MyClass{

private MathClass myCalculator;

private int x;

// Constructor
public MyClass(int myInt){
myCalculator = new MathClass();

x = myInt;
}

public void compute(){
myCalculator.square(x);
}


}


You can pass in values as parameters when initializing the class object.
As in (in a different class let's say called AplleClass, you did) MyClass object = new MyClass(5);
The 5 in the above text is because we passed in 5 as a value. So now x is equal to 5.

I hope I didn't mess up somewhere lol. Someone correct me if I said or did something wrong.
+2 Branislav Lazic · July 1, 2015

constructor is actually a special function inside class and can be called directly so it is "public" and it's main purpose is to construct an object instant of that specific class with default values or given parameters... So?!


Constructor is not necessarily "public". So basically, what someone will think after his tutorial: "Ok if it's public it's constructor. If it's private... ok well.. then it's not a constructor!" And no, it's not a method. It looks like a method, but it's not.
0 M .A.K · July 1, 2015
constructor is actually a special function inside class and can be called directly so it is "public" and it's main purpose is to construct an object instant of that specific class with default values or given parameters...  So?!
0 mike richardson · June 30, 2015
Well seeing as it will probably not get remade what part do you not understand?
0 Branislav Lazic · June 30, 2015
Long time ago, I was pointing at totally wrong presentation approach of those tutorials. Nobody cared. 
Just listen him: "We know it's a constructor because it's "public"." Lol? Calling constructor a method? Does this guy have any clue at all?
+1 Muamet Shasivari · June 30, 2015
Finally someone started to complain about C# videos and asking for a remake.Great news.I will ask same.
+1 Alinous Alinous · June 30, 2015
Yeah, the remake of C# tutorials would be great. They're pretty good, but quality is horrible ( if you want to see what does he write, you have to chose 1080p, rly?). As Cardinal already said, few things are a bit confusing for a newbie.
  • 1

C#

107,088 followers
About

C# is an object-oriented language designed for improving the development of web applications.

Links
Moderators