web design
  • January 19, 2009 by Mark.C

    How to declare variables in the .NET framework using C#

    DEFINITIONS:
    A variable is a specific location used to store data. In order to declare a variable you have to state a data type. Some common data types are:

    int // used for integers
    double // used for real numbers
    bool // used for true or false statements
    string // used for a sequence of text characters

    HOW TO:
    Examples of declaring ints:

    int x, xillent, Xillent, XillentCorp; // declares an int
    int x = 0; // initializes x to an integer, in this case 0

    Examples of declaring doubles:

    double x, X, Xillent, XillentCorp; // declares a double
    double x = 4.5; // initializes x to a real number, in this case 4.5

    Examples of using bool:

    bool x, xillent, Xillent, XillentCorp; // declares a bool
    bool x = true; // initializes x to true

    Examples of using string:

    string x, xillent, Xillent, XillentCorp; // declares a string
    string x = “Xillent is a website design company.”; // initializes x to a string, in this case “Xillent is a website design company.”

     

    One Comments

    1. Timur Alhimenkov says:
      January 27, 2009 at 5:21 pm

      Great! Thank you very much!
      I always wanted to write in my blog something like that. Can I take part of your post to my blog?
      Of course, I will add backlink?

      Sincerely, Timur I. Alhimenkov

    Leave a Comment

    • required  
    • required  
    •