Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent syntax in C#, if any? [duplicate]

Does C# have any equivalent for VB6

With 
End With
like image 913
abhi Avatar asked Nov 29 '10 15:11

abhi


People also ask

What is equivalent in C?

C *= A is equivalent to C = C * A. /= Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. C /= A is equivalent to C = C / A.

What is meaning of += in C?

+= Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand. C += A is equivalent to C = C + A. -=

How many syntax does C have?

The Complete List of all 32 C Programming Keywords (With Examples) - Programiz.

What is syntax error in C?

Syntax errors are mistakes in the source code, such as spelling and punctuation errors, incorrect labels, and so on, which cause an error message to be generated by the compiler.


1 Answers

There's nothing quite equivalent, but C# 3 gained the ability to set properties on construction:

var person = new Person { Name = "Jon", Age = 34 };

And collections:

var people = new List<Person>
{
    new Person { Name = "Jon" },
    new Person { Name = "Holly"}
};

It's definitely not a replacement for all uses of With, but worth knowing for some of them.

like image 75
Jon Skeet Avatar answered Oct 02 '22 18:10

Jon Skeet