Objects in C#

Objects in C#

In C#, everything is treated as an object. Objects contain data and have methods that operate on them. For example, strings are now objects. They have methods such as

 

Substring

ToLowerCase

ToUpperCase

IndexOf

Insert

and so forth.

Integers, float and double variables are also objects, and have methods.

 

string s;

float x;

x = 12.3;

s = x.ToString();

Note that conversion from numerical types is done using these methods rather than external functions. If you want to format a number as a particular kind of string, each numeric type has a Format method.

 

Shashi Ray

Ebook Download
View all
FileInfo in C#
Read by 9.7k people
Download Now!
Learn
View all