C Sharp Variable Declaration Tutorial Videos for Beginner - PowerPoint PPT Presentation

About This Presentation
Title:

C Sharp Variable Declaration Tutorial Videos for Beginner

Description:

C Sharp Variable Declaration Tutorial provides brief explanation on Declaring varible using strings.Courseing provides best online,videos and classroom training institutes for C sharp for beginners. – PowerPoint PPT presentation

Number of Views:37

less

Transcript and Presenter's Notes

Title: C Sharp Variable Declaration Tutorial Videos for Beginner


1
C Declaring Variables Tutorial Videos for
Beginners by
2
Highlights
  • Declaring variables
  • Using built-in data types
  • Working with characters
  • Working with strings
  • Building strings with String Builder
  • Parsing strings as numbers

3
Declaring variables
  • variable is a name given to a storage area that
    our programs can manipulate.
  • Integral types, Floating point types, Decimal
    types, Boolean types, Nullable types are basic
    value types in C.
  • Syntax for variable definition ltdata_typegt
    ltvariable_listgt
  • EX int i, j, k char c, ch float f, salary
    double d
  • Syntax for Initializing Variables ltdata_typegt
    ltvariable_namegt value
  • Ex int i 200

4
Using built-in data types
  • Byte, sbyte, short, ushort, int, uint, long,
    ulong, float, double, decimal, char, string
  • bool, object are C built-in data types.
  • Built-in data types are used within a C program
    in several ways like as variables,
     constants, return values and parameters
  • Syntax int answer 42 const int speedLimit
    55 long CalculateSum(int a, int b) long result
    a b return result
  • variables in C categorized into three types,
    they are value types, reference types pointer
    types

5
Using built-in data types
  • Reference types do not include the data stored in
    a variable, but they contain a reference to the
    variables. Object, dynamic, and string
    are reference types.
  • Object Type is the ultimate base class for all
    data types, dynamic types store any type of value
    in the dynamic data type variable, String
    Type allows you to assign any string values to a
    variable.
  • Pointer type variables store the memory address
    of another type. 
  • Syntax type identifier

6
Working with characters
  • Char keyword is used to declare an example of
    the System.Char
  • Char is a value type represents a character.
  • Char must be used when converting to an integer.
  • Char  type can be implicitly converted
    to ushort, int, uint, long, ulong, float, double,
    or decimal types.
  • Value of a char object is a 16-bit numeric value.
  •  System.Char type provides numerous static
    methods for working with char values.

7
Working with strings
  • String is basically a sequence of characters,
    used to declare a string variables.
  • String keyword belongs to the System.String
    class. Many methods been provided in C to create
    string objects.
  • String objects can be created by assigning a
    string literal to a String variable, using a
    String class constructor, by string concatenation
    operator.
  • Char , length are the properties and compare,
    concat, copy, equals, index, join, remove,
    replace, split are various methods of string.

8
Building strings with String Builder
  • System.Text.StringBuilder class can be used to
    create strings without creating a new object.
    Syntax for creating strings is as follows
  • StringBuilder MyStringBuilder new
    StringBuilder("Hello World!")
  • StringBuilder class can boost performance when
    concatenating many strings together in a loop.
  • Unlike a string, a StringBuilder can be changed.
    Using StringBuilder  a string can be appended
    many times.

9
Parsing strings as numbers
  • TryParse method or Convert class methods are used
    convert a string to a number.
  • Ex int numVal Int32.Parse(253")
  • Console.WriteLine(numVal)
  • Output 253
  • int j
  • if (Int32.TryParse(253", out j)
  • Console.WriteLine(j)
  • else Console.WriteLine("String could not be
    parsed.")
  • Output 253

10
Feedback
Like It ? Hate It?
We would love to hear from you whatever you think
about the course.
Click HERE to share what you think!
11
Thank you
Thank You for Watching C Managing Data
Collections Tutorial Videos for Beginner by
http//www.courseing.com
Write a Comment
User Comments (0)
About PowerShow.com