Equivalent for with keyword in C#

Posted by Nishithraj under C# on 2/28/2010 | Views : 4366 | Status : [Member] | Replies : 4
Is there any keyword equivalent to "with" keyword in C#

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan



Responses

Posted by: Vuyiswamb on: 2/28/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Evening Nishithraj

i dont think there is one. But C# has some cool shortcuts too.

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 2/28/2010 [Member] Starter

Up
0
Down
Hi Vuyiswa,

Thanks for responding to this post. However, just wanted to tell you one thing, the statement you have written "But C# has some cool shortcuts too" looks very generic and that may not help Nishith in any way, instead it would have been better if you would have given some details about those shortcuts that is available in C# that might have helped him.

Please do not mind, this is just my feeling.

Regards



Regards,
Raja, USA

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 2/28/2010 [Member] Starter

Up
0
Down
Sorry, once again :)

Vuyiswa is right there is not one equivalent in C#. Following post will tell you why it is not and help you to get some alternatives.

http://forums.asp.net/p/61373/61373.aspx
http://bytes.com/topic/c-sharp/answers/236554-equivalent-c

Thank you.

Regards,
Raja, USA

Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gttejas on: 3/18/2010 [Member] Starter

Up
0
Down
Hi,

From C# 3.0, there is one new feature called Object initializer will do something like this.

For example,

lets say i have one class

class test
{
public int id {get;set;};
public string name {get;set;};

}

now,
public static void main()
{

// here i can write something like this which is somewhat similar to with syntax
test a=new test()
{
id=10,
name="tejas"
}
}



Nishithraj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response