C# Constructors Tutorial | Mosh

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 160

  • @drabantorgreyhound6613
    @drabantorgreyhound6613 7 років тому +118

    Clear voice, clear audio quality, good display resolution and last but not least good content presented in a pedagogical way, thanks!

    • @pspicer777
      @pspicer777 5 років тому

      Drabantor Greyhound Your comment is interesting as it is surprising how often these types of videos are unusable because they miss the mark on one of your criteria.

    • @dweebosupremo5904
      @dweebosupremo5904 4 роки тому +2

      i actually feel that the voice is too bass-y and hard to understand.

    • @Rovsau
      @Rovsau 4 роки тому +1

      This()

    • @ppogd9795
      @ppogd9795 3 роки тому

      my mom asked on 13 o-clokc. what dosse ""pedagogical """""""" menanmean

    • @ppogd9795
      @ppogd9795 3 роки тому

      ow i q on q q# me fulenrt
      s

  • @leuk2389
    @leuk2389 5 років тому +16

    This was very smooth and easy to follow, thank you!
    For those not using ReSharper when making a new class do not add a namespace and if it has one remove it or your class will not work!

  • @XXIcenturyblood
    @XXIcenturyblood Рік тому +1

    0:06 - What is a constructor?
    0:15 - Why need a constructor?
    0:25 - Declare constructors
    3:28 - Constructor overloading
    4:49 - Demo

  • @tollinroth5939
    @tollinroth5939 3 роки тому +2

    Thank you for your tutorials. They have been very helpful. If I may offer something in return, hold down "Ctrl + Shift + A". That is the keyboard shortcut for creating a "new something" for example the first item is often a new class. Just title it and hit enter. Saves time manually right clicking and searching. Thank you again for your help :)

  • @CrazyUnknownObject
    @CrazyUnknownObject Рік тому

    After watching the tutorial I understand the 'this' explanation within 10min. Awesome!

  • @DarthJeremy364
    @DarthJeremy364 5 років тому +18

    "you should code like a ninja"....yes yes this is exactly what i want

  • @MrBaiins
    @MrBaiins 5 років тому +5

    Good tutorial. Resharper is great but right clicking add class isn't a big deal, don't turn it into one. Most people here aren't professionals we are just here to learn. It's good to learn how to do things manually especially as newbies.

  • @lukefox836
    @lukefox836 5 років тому +12

    Thank you for the dark background.

  • @sunova_
    @sunova_ 2 роки тому +2

    This was very helpful! Especially how you go thru the examples step by step. But furthermore, you provide best practice too. Superb!

  • @johnconnor9787
    @johnconnor9787 5 років тому +2

    Thank you. I did not know that when we create a constractor, the default one disappears and we need to declare parametrless constractor. You answered the question I had so many troubles with)) I wish I watched this earlier)) Thank you

  • @preslavdelchev1203
    @preslavdelchev1203 5 років тому +1

    That's what i call a great video. Excellent job! Simple and well explained, even a kid can understand it

  • @BijouBakson
    @BijouBakson 2 роки тому

    You can tell it's a paid course. Very detailed and considerate. Thank you.

  • @PouryaKamyarfard
    @PouryaKamyarfard Рік тому

    "Code like a Ninja"! This is the qoute that will form my career!

  • @babaktirgar
    @babaktirgar 7 років тому +16

    Hi Mosh,
    Your Tutorials are incredibly Perfect! Thanks a lot.
    I really Suggest everyone to try them!!

  • @jjovanw
    @jjovanw 6 років тому

    This is the best explanation of C# concepts I have ever seen. Keep up the good work!

  • @olekristianrannekleiv762
    @olekristianrannekleiv762 2 роки тому +3

    If you get an error when running the code, double check that you Console.WriteLine(costumer.ID) and not console.WriteLine(Costumer.ID) with a capital C. if you use capital C you try to output the class ID and not the object you created from the class.

  • @The_DLK
    @The_DLK 6 років тому +4

    Thank you mate , u made constructors sooo easy to understand and perfect please keep providing these videos ^_^

  • @moldovandorin6187
    @moldovandorin6187 4 роки тому

    mosh...you are a wonder of the universe

  • @gregkoonce3059
    @gregkoonce3059 7 років тому +7

    Code like a Ninja!

  • @dominiquedevries9972
    @dominiquedevries9972 4 роки тому

    You are the best with Visual Studio!

  • @danieliglesias5805
    @danieliglesias5805 4 роки тому

    Finally a really nice tutorial about constructors, thanks!

  • @HeyMr.OO7
    @HeyMr.OO7 Рік тому

    Best coding instructor

  • @emanandchill
    @emanandchill 7 років тому +2

    Thanks. Very good info. I had to find another c# tutorial for constructors and I found you. I learned a lot. Going to subscribe.

  • @sevensrikanth
    @sevensrikanth 5 років тому +1

    code like a ninja... well said...

  • @investingwitha-aron8055
    @investingwitha-aron8055 Місяць тому

    Clear and understandable. Thank you. I subscribed.

  • @bogdanmitroii6159
    @bogdanmitroii6159 3 роки тому +2

    Why not.. In the Costumer Class, as a property.. you don't type this =
    public List Orders = new Lisy() ;
    And it will be always initialized without using a Constructor. Why not?

  • @tonismith1445
    @tonismith1445 6 років тому

    So this is definitely more advanced topic than I am ready for. About half way through I'm literally just sitting there wondering what the heck he is even doing because I have no idea what constructors are and these other advanced topics. I'm going do some more reading and practicing and hopefully return to this topic later on when I know what a few of these things mean. However, that being said it's a good tutorial talking about Code Sharpner ect just not for beginners like myself at this time.

  • @omarelshayeb3492
    @omarelshayeb3492 5 років тому +7

    I laughed when you said you should code like a ninja :'D

  • @NestedMango
    @NestedMango 5 років тому +1

    Great tuto..Sir...By using C# We can Make 2d and 3d game on Unity game engine. Unity is free.

  • @brunoh1673
    @brunoh1673 5 років тому +2

    great tutorial ! Mosh you are a programming genius!

  • @namronmanelok4119
    @namronmanelok4119 3 роки тому

    This is really easy to follow and understand. Excellant!

  • @khazar5790
    @khazar5790 6 років тому +3

    Great tutorial for constructors concept, thanks a lot!
    I just got a bit confused at the end when you describe about list of orders, it could be better to put an example there (rather than empty list maybe?).

    • @gowthammech1990
      @gowthammech1990 4 роки тому

      agree

    • @olekristianrannekleiv762
      @olekristianrannekleiv762 2 роки тому

      the list is basicaly a box you can store things inside. "list" tells the program to make a box you can put things inside,
      "" describe what you are allowed to put inside this box. In this case only objects created by the class "orders" are allowed to be put inside this box. if he wrote list you could only put strings inside the box. It is abit confusing that he used a custom designed object as an example for what to put inside a list, i agree...

  • @MohamedIbrahim-uk7mj
    @MohamedIbrahim-uk7mj 6 років тому +3

    you are the best really

  • @nitro-ww6sk
    @nitro-ww6sk 5 років тому

    High quality tutorials, worth your time!!!

  • @bahtiyorusmanov7211
    @bahtiyorusmanov7211 4 роки тому

    Easy to understand explanation, thank you!

  • @miablazekovic1125
    @miablazekovic1125 6 років тому +5

    Super awesome tutorial, thank you so much! :)

  • @annastaniszewska2172
    @annastaniszewska2172 3 роки тому

    In all his videos about C#, Mosh is basically telling us "If you don't have Resharper, I'm sorry for you" and I'm actually very sorry for me cause of that :< I had it once, now I don't and it's such a loss...

  • @pritamd7k
    @pritamd7k Рік тому

    Great , as usual Mosh!
    Looking for more videos on c# containing xUnit test case advance methods.

  • @amandabos6166
    @amandabos6166 4 роки тому

    thank you Mosh, you taught me more in 23 min than my teacher at school in 4 hours :-)

  • @talk2s5061X
    @talk2s5061X 3 роки тому

    code like a ninja I like this guy!!!

  • @mylifeinvictus
    @mylifeinvictus 7 років тому +1

    Dude, thanks so much for your tutorials! They are great!

  • @erimun
    @erimun 6 років тому +1

    I like your explanation.Thanks.

  • @owencoopersfx
    @owencoopersfx 2 роки тому

    Excellent explanation. Thank you 🙏

  • @rasheedram200
    @rasheedram200 5 років тому +1

    Keep up the good work (Thank you very much for this great tutorial)

  • @mjollnirminchan7221
    @mjollnirminchan7221 4 роки тому

    Thank you for your good work♪...all your videos are truly heplful...i wish you a good health♡

  • @rtridico911
    @rtridico911 5 місяців тому

    Great video! Thank you so much!

  • @dave-th6yu
    @dave-th6yu 4 роки тому

    You are amazing!!!!!
    Thank you Mosh!!!!!

  • @ukaszk4410
    @ukaszk4410 6 років тому

    I have a question. Why after you run it in 13:04 you get "press any key to continue"? For me the breakpoint makes it print only "1" and "John" is not displayed. I added Console.ReadLine() after and removed the breakpoint to get a similar effect, but I like your way much better. Please tell me how to get it this way. And anyway thanks a lot for this video!

  • @יוניארליך-ע5פ
    @יוניארליך-ע5פ 4 роки тому

    YOU HELPED ME A LOT!!

  • @robertmarczak3991
    @robertmarczak3991 4 роки тому

    Another Good one. Thanks Mosh.

  • @Ali7Dali
    @Ali7Dali 5 років тому +2

    Hi Mosh, thank you for the great video!
    I have a question:
    is it wrong to initialize variables or objects once you declare them instead of doing that in the constructor??
    Thanks in advance!

    • @mortyjr2334
      @mortyjr2334 5 років тому +1

      He uses a default constructor to initialize the List, this in itself is bad practice and should be done inline within the field itself, so the field should look like this:
      List orders = new List();
      NOT:
      List orders;

  • @fjeanjoseph
    @fjeanjoseph 3 роки тому

    Awesome tutorial - Thank you so much!

  • @dembasiby
    @dembasiby 4 роки тому

    Thank you, Mosh!

  • @princemalongo9303
    @princemalongo9303 2 роки тому

    I have over understood. Everything here is clear.

  • @christofstanits
    @christofstanits 7 років тому

    amazing tutorial! so very well explained!

  • @rawal16
    @rawal16 6 років тому +1

    Great Mosh

  • @anamnasirrollno0838
    @anamnasirrollno0838 4 роки тому +1

    you are amazing!

  • @crabsynth3480
    @crabsynth3480 6 років тому

    19:40 - Wow ... beauty ... that made me so happy :) !
    : Ouch seconds later u made me realize that its actually ugly. How do you do that ? haha

  • @srinivasaraoyp3640
    @srinivasaraoyp3640 5 років тому

    Very interesting sir. Thank you..

  • @dafiarecord72
    @dafiarecord72 5 років тому +1

    Hey, thanks a lot, great videos in this channel, i subscribe, everything is clear.
    voice/presentation/Steps order, i learn more from u, thanks for all.

  • @Nathan-nj6kt
    @Nathan-nj6kt Рік тому

    Hello Mosh, thank you for your videos, taking time to record these videos are helpful. I however recommend you stop using the same names twice. In the previous video you mentioned "person Person"; this can be very confusing, here again we have "Customer Customer". For the first example you could use "person Student" or something different. This would reduce explanation and learning easier. thank you. thank you.😊

  • @everythincomesaround
    @everythincomesaround 3 роки тому

    Great video. I just did't get it with the list of objects. Do you always need to initialize these lists of objects in a constructor?

  • @YPLabs
    @YPLabs 6 років тому

    Thank you Mosh!

  • @OriginalTubester
    @OriginalTubester 6 років тому +1

    Great video, thank you

  • @יוניארליך-ע5פ
    @יוניארליך-ע5פ 4 роки тому

    YOU ARE GREAT

  • @morty4815162342
    @morty4815162342 3 роки тому

    very helpful, thanks

  • @TechnicalAkshay
    @TechnicalAkshay 5 років тому +1

    who here after trying sololearn but not understand constructers

  • @amirprogramming6963
    @amirprogramming6963 5 років тому

    thank you :)
    I suggest you if you could set some exercise , then we can practice it

  • @Nick-wz6tz
    @Nick-wz6tz 4 роки тому

    Thank you very much sir !

  • @yoanngrudzien2588
    @yoanngrudzien2588 4 роки тому

    I'm new at coding and wanna make sure I learn the correct conventions, I have a question :
    Shouldn't we be using camelCase for fields ? I learned that PascalCase was supposed to be used for properties.
    ex :
    public class Human
    {
    //camelCase for the field :
    public int age;
    //PascalCase for the property:
    public int Age
    {
    get {return age;}
    set
    {
    if (value < 0)
    { age = 0; }
    else
    { age = value; }
    }
    }
    }
    Thank you in advance to whoever answers me.

  • @zuque6199
    @zuque6199 6 років тому

    Thank you so very much for the help!

  • @sethell2
    @sethell2 4 роки тому

    7:43 can someone explain to me the explicit way of writing var customer out? Thanks

  • @teebear2271
    @teebear2271 2 роки тому

    Time stamp 19:38

  • @aliciavegas5287
    @aliciavegas5287 2 роки тому

    do you give private lessons ?

  • @mikeafter5
    @mikeafter5 3 роки тому

    Thanks!

  • @chrisalbers9184
    @chrisalbers9184 4 роки тому

    Thank you!

  • @darthnixilis304
    @darthnixilis304 4 роки тому

    These videos are great, just i wish you wouldnt use a $300/yr extension. The reason people are watching videos on youtube instead of paying for a class is because we're broke. I wish i could spend that kind of money to on an extension.

  • @fahimehramezan3521
    @fahimehramezan3521 5 місяців тому

    🥰🥰Thank you

  • @rahimeinollahi1
    @rahimeinollahi1 6 років тому

    Thank you very nice.

  • @darkrist
    @darkrist 4 роки тому

    :D i love the channel, I love the teaching methods!

  • @BGraves
    @BGraves 2 роки тому

    Typical for programmers to call it "overloading" just to convolude and confuse with a term that carries a negative connotation.

  • @coronicrefugeestofffic6753
    @coronicrefugeestofffic6753 2 роки тому

    i was missing the static void string and was thinking it was cause i didnt have the handy dandy shrtcuts u got

  • @ivanfenis1221
    @ivanfenis1221 5 років тому

    Hi Mosh. Thanks for explaining this topic well :).
    I just want to ask why "this." isn't needed for the "Orders" when you initialized it in the first Customer constructor? So "this.Orders = "

    • @thisisbob1001
      @thisisbob1001 5 років тому

      Maybe because it is in the default constructor you don't need thi? docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors

  • @1986hr
    @1986hr 6 років тому +1

    Ok this is useful.

  • @truetrueman680
    @truetrueman680 4 роки тому

    What is the difference between constructors and classes? I'm a totally new when it comes to programming so sorry if I'm asking a dumb question

  • @timeforrice
    @timeforrice 2 роки тому

    Can you make a video like this for Interface?

  • @boblewis1287
    @boblewis1287 3 роки тому

    Not to put an object in an early stage. It's to instantiate and initialize an object.

  • @1spunch
    @1spunch 6 років тому

    Clear voice. Talk only good way to do it, I think it will make more clear., not confused

  • @bongemhoangtu2468
    @bongemhoangtu2468 6 років тому

    Hi can I ask something can you help me with the errors in visual studio with connect string
    : 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
    Thanks you

    • @poloska9471
      @poloska9471 4 роки тому

      You probably know this by now, but for other people:
      Make sure that your IP address is whitelisted or the IP permissions constraint is disabled.
      Make sure that you spelled everything correctly and did not include the "..." in the server URL (include only: " some-server-name.database.windows.net ").
      Make sure that you specified the correct initial database name.
      Make sure that you provided all the minimum necessary parameters and the correct order when connecting via a connection string.
      Make sure that the database server and database are available for remote connections.
      Good luck!

  • @3rdtwirl494
    @3rdtwirl494 2 роки тому

    Hello. We would like to know more about building - well one day - forex trading bot . Where do we start

  • @johnconnor9787
    @johnconnor9787 5 років тому

    Are your courses on udemy and codewithmosh com the same? If not then what is the difference between them
    Thank you

  • @chelebarry
    @chelebarry 6 років тому

    :'( I had problems understanding this topic hope I understand as I follow along...

  • @d-abdullah-b2191
    @d-abdullah-b2191 4 роки тому

    When you creat the Customer object ,why did you put var instead of Customer?

  • @kensei4237
    @kensei4237 4 роки тому

    I kinda don’t like the excessive promotion of resharper here, but all in all nice tutorial. Also, it’s not a good practice to use many shortcuts, because at some point you won’t have VisualStudio as an ide and you’ll have to know what to type. Cheers.

  • @hamedsaidalrawahi4082
    @hamedsaidalrawahi4082 6 років тому

    thank you

  • @kunalsahadeva1940
    @kunalsahadeva1940 5 років тому +1

    Can you please use white theme for visual studio

    • @VoidlingGeneral
      @VoidlingGeneral 5 років тому +1

      NEVER dark mode is the future now!

    • @thisisbob1001
      @thisisbob1001 5 років тому

      @@VoidlingGeneral that's how it was back in the 80s!

  • @HaloWolf102
    @HaloWolf102 3 роки тому

    What is the difference between
    var order = new Order()
    &
    customer.Orders = new List();
    Also, I can't put var order = new Order() in the Customer() class. VS always tells me that I need another instance. So I always instance twice, instead of once.

  • @junejuly532
    @junejuly532 4 роки тому

    After watching this, i realized that I've wasted my parent's monies in school.

  • @Mickey-w6d
    @Mickey-w6d 7 років тому

    public List Orders { get ; private set;} Maybe good

  • @mrskujo4359
    @mrskujo4359 5 років тому +1

    hey mosh when i create a new object order it shows error in my program