Thursday, December 13, 2007

Properties in C#

Properties , As there are lot of things going on in my life regarding hike in Bangalore properties ,…..

Here I am trying to understand properties in C#

properties are nothing but natural extension of data fields

Here is an simple example which explain diff between code using properties and not using properties .

With out using properties

using System;
class MyClass
{
private int x;
public void SetX(int i)
{
x = i;
}
public int GetX()
{
return x;
}
}
class MyClient
{
public static void Main()
{
MyClass mc = new MyClass();
mc.SetX(10);
int xVal = mc.GetX();
Console.WriteLine(xVal);//Displays 10
}
}

Syntax for properties


{
get
{
}
set
{
}
}

Where can be private, public, protected or internal. The can be any valid C# type. Note that the first part of the syntax looks quite similar to a field declaration and second part consists of a get accessor and a set accessor.

If we use properties, the code sample will be

using System;
class MyClass
{
private int x;
public int propertyValue
{
get
{
return x;
}
set
{
x = value;
}
}
}
class MyClient
{
public static void Main()
{

MyClass mc = new MyClass();
mc.propertyValue = 10;
int xVal = mc.propertyValue;
Console.WriteLine(xVal);//Displays 10
}
}

mc.propertyValue = 10; // calls set accessor of the property propertyValue, and pass 10 as value of the standard field 'value'.
This is used for setting value for the data member x.
.

For more info you can visit this link

http://www.c-sharpcorner.com/UploadFile/rajeshvs/PropertiesInCS11122005001040AM/PropertiesInCS.aspx

Thursday, December 6, 2007

Cast Conversion

I am not talking about Cast conversion in C#

Its a cast conversion which is happening in India,..

I belive everyone has rights to follow there owne religions....,

But , In India there are some mechinaries which are converting poor Hindus in to christinas by saying " we will give better life" .

But , I feel its exploitaions ,...

I had a freind who is basically from Ooty, and he is a christian,.... While talking with him , I got to know one surprising thing.

He said his father was converted christian and mother was brahmin Hindu ,..and they have to face lot of problems because of Intercast clashes...

and he is telling Even thoe he like Hinduism very much he cant convert from Christian to Hindu ,..because once the christian community of them came to know that you are not coming to church or not following rules they will not even give a small piece of place to burry you after your death,..

and also, he said like In hindues there is no rule that to follow hinduism you have to come to temple or you have to do any particular thing,..
with out becoming hindu also you can always follow Hindu's way of life,..
so he is celebrating all Hindu festival and also going for church ..

There may be many people in india who may be living with these type of clashes,..

As a Hindu I certainily like Hinduism but it doesnt mean that I have to hate Muslim relegions and christianity,...
Same way I excepect Muslim and christians should not say Hinduism is wrong..

I personally ,...Completly oppose converting people from one religion to another,..

and I personally feel people who convert like that may not be having there owne mind set ,..

All religions say live your life happily and join god after your death ,..so whatever religion you follow,..How you live in life will matter ,...