Blog - Title

  • The C# Team

    What's the difference between string and System.String?

    C# defines a number of aliases for CLR types. They may be used interchangably, and even mixed together, e.g. string x = new System.String(' ', 5); . These are the aliases defined: Alias CLR type string System.String ...
  • The C# Team

    What's the difference between an event and a delegate?

    Put simply, an event gives more limited access than a delegate. If an event is made public, code in other classes can only add or remove handlers for that event; they can't necessarily fire it, find out all the handlers for it, or remove handlers...
  • The C# Team

    Why can't I use static and const together?

    All constants declarations are implicitly static, and the C# specification states that the (redundant) inclusion of the static modifier is prohibited. I believe this is to avoid the confusion which could occur if a reader were to see two constants...
  • The C# Team

    What character escape sequences are available?

    C# defines the following character escape sequences: \' - single quote, needed for character literals \" - double quote, needed for string literals \\ - backslash \0 - Unicode character 0 \a - Alert (character 7) \b - Backspace...
  • The C# Team

    What does an @ before the start of a string literal mean?

    A string literal such as @"c:\Foo" is called a verbatim string literal . It basically means, "don't apply any interpretations to characters until the next quote character is reached". So, a verbatim string literal can contain backslashes (without...
  • The C# Team

    How are parameters passed in C#? Are they passed by reference or by value?

    By default, all parameters are passed by value in C#. Parameters are only passed by reference if you explicitly include an out or ref modifier. However, you need to be aware that when the type of the parameter is a reference type, you're passing...
  • The C# Team

    Does C# have templates like C++?

    Although C# doesn't have templates, and isn't likely to get them, it is getting a feature called generics which will be available in the next version of .NET and Visual Studio. Generics will be a feature in the CLR itself, and most languages targetting...
  • The C# Team

    Why doesn't C# have VB.NET's 'with' operator?

    Many people, including the C# language designers, believe that 'with' often harms readability, and is more of a curse than a blessing. It is clearer to declare a local variable with a meaningful name, and use that variable to perform multiple operations...
  • The C# Team

    What are the advantages of C# over VB.NET and vice versa?

    The choice between C# and VB.NET is largely one of subjective preference. Some people like C#'s terse syntax, others like VB.NET's natural language, case-insensitive approach. Both have access to the same framework libraries. Both will perform...
  • The C# Team

    Where is the C# specification?

    There are two versions of the C# specification - one from Microsoft, and one from ECMA. They are the same in all important respects (a few pieces of explanatory wording are different, but nothing that affects the specification itself) but the numbering...
  • The C# Team

    Why don't relational operators return bool as a type?

    Section 10.9.2 of the language specification says: A binary operator must take two parameters, at least one of which must have the class or struct type in which the operator is declared. Parameters of the shift operators ( § 7.8 ) are further...
  • The C# Team

    Why doesn't C# support #define macros?

    In C++, I can define a macro such as: #define PRODUCT(x, y, z) x * y * z and then use it in code: int a = PRODUCT(3, 2, 1); C# doesn't allow you to do this. Why? There are a few reasons why. The first is one of readability. One of our...
  • The C# Team

    Why don't namespace using directives import nested namespaces?

    In C#, when you specify a “using” clause, such as using System.Text; the compiler only imports the types in System.Text into the global namespace - it doesn't do the same with any namespaces inside of System.Text. So, while that using...
  • The C# Team

    Why doesn't C# have a power operator?

    Some languages provide a power operator, so one can write something like: float result = value^2; rather than having to resort to calling. We don't have one in C#. It would be possible to add a power operator to the language, but performing this...
  • The C# Team

    Why doesn't C# support multiple inheritance?

    This answer is from Chris Brumme via the following post . I've copied the text in here in case the post disappears. *** There are a number of reasons we don't implement Multiple Implementation Inheritance directly. (As you know, we support Multiple...
  • The C# Team

    Does C# have default parameters?

    Update: Named and optional (default) parameters are available starting from C# 4.0. For more information, see Named and Optional Arguments (C# Programming Guide) . In languages such as C++, a default value can be included as part of the method...
  • The C# Team

    Ask a FAQ Question

    Do you have a FAQ about: The C# Language or compiler The C# IDE The Visual Studio debugger Reply to this post, and your question will be added to our list to be answered. Of course, depending on the nature of your comment, and the volume...
Page 6 of 6 (142 items) «23456