Student Of Fortune

C# Tips, Implementation Of String In C#

Share on :
String is a data type formations such as array, even string can be called an array of char, which is an array of char data type (character), thus forming a new data type that can store any other arrangement of letters or characters.
See The Following Code :
using System;
namespace InputOutput
{
    class Program
    {
        static void Main(string[] args)
        {
            String name = Console.ReadLine();
            Console.WriteLine("Name : " + name);
        }
    }
}
If we compile the above program will ask for input from the user and displays them on screen, the output of the above program is:
See The Output Code :
Name : Ajonksb
In addition we can also do a fabrication of the string data type by using the methods, for example, printing a string in reverse order as in the example below:
See The following Code :
using System;

namespace String

{
    class Program
    {
        static void Main(string[] args)
        {
            string word = "abcdefghij";
            char[] x = word.ToCharArray();
            for (int i = word.Length - 1; i >= 0; i--)
                Console.Write(x[i]);
        }
    }
}
So when we compile the program output is not a string "abcdefghij" but precisely the opposite is "jihgfedcba".
word.Length () methods is used to obtain the length of the string. In this case the length of the string is 10, for counting starts from 0, so the character "a" in stringg is located on the index-0 and the character "j" is at index to "9 ".

0 comments on C# Tips, Implementation Of String In C# :

Post a Comment and Don't Spam!

Dont Spam please

 
Recommended Post Slide Out For Blogger

Recent Comments

My Rank