Declaring Variables and Assigning Values - Day 1 - Part 9

Download this episode

Download Video

Description

We now focus on learning the C# programming language. In this video, Bob explains variables and data types, as well as setting and retrieving variable values.

Download the source code in c#

Download the source code in VB.Net

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Mintydog

      Good video but I ran into a problem. When you typed y.ToString square braces appeared at the end [ ] but that doesnt work for me, it does work however if I use the curved braces ( ), I don't understand why

    • User profile image
      Digital Dave

      I was also JUST watching the video and I watched the same thing and was about to comment on it. Really cool but can you please explain the () at the end and how, if we had not seen it we would have known to put the () at the end of the line.

    • User profile image
      Tony

      [quote]
      1 day ago
      I was also JUST watching the video and I watched the same thing and was about to comment on it. Really cool but can you please explain the () at the end and how, if we had not seen it we would have known to put the () at the end of the line.

      [/quote]
      It's part of the syntax of C# but you really didn't need to know that because when you put the . after y the intellisense auto-completion added the () to the end after you selected .ToString().  Visual Studio would have told you that this was a problem as well.  I think it even goes so far as to tell you that it expects parentheses.

    • User profile image
      Clint

      @Mintydog: brackets in a C style language like c# implies an index to an array or collection.  so if I had an array of integers called foo that has 10 objects, I'd go

      int firstInt = foo[0]; // returns first
      int fifthInt = foo[4]; // returns 5th in array

      Now () is typically for methods and constructors.  so if I have an a string, I'd go

      string myString = new string();

      If I have an integer and wanted to change it into a string, I have to cast it.  Since .ToString is a method, I have to do use () since some methods allow you to pass stuff in.  With (), I'm passing in nothing.

      int five = 5;
      string theNumberFive = five.ToString();

    • User profile image
      Joseph Clover

      He did infact use 'toString()'. It is because of the video quality that it appeared as '[]'. :)

    • User profile image
      Clint

      @Joseph Clover: Ah, we do have the high quality versions and the source code examples for download as well for each video

    • User profile image
      Kavitaj

      @Clint: Where can I find the high quality versions. The quality is pathetic in these. Can't read a word!

    • User profile image
      Miso

      where can i change the settings to have these () after ToString,too?

    • User profile image
      TechieGirl1

      This is too funny!

    • User profile image
      TechieGirl1

      Clint,
      Just wanted to tell you I think you are doing a fantastic job with these videos. Thanks for putting these together for everyone.

      TechieGirl1

    • User profile image
      Brady

      Totally new to all this but downloaded the latest tools (the beta) and it seems that the conventions for defining variables is different than the video. Using the Dim string instead of Int?

      I'm confused. Can anyone help?

    • User profile image
      Brady

      Again, a total newbie but it seems like when I try to edit actions on a control I'm working in VB and he's working in C#. Does that make sense and how do I switch?

    • User profile image
      Brady

      Nevermind, I'm a moron. Figured it out.

    • User profile image
      deva_p

      Thanks All these videos are great tutorials!

    • User profile image
      BrunoMaestro

      Good video, thanks.

    • User profile image
      Philip Goff

      First off excellent video's, thanks for posting them.I am a total norvice, can you tell me how you convert doubles to string please.

      Thank you in advance.

      Regards Phil

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.