Blog - Title

  • The C# Team

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

    • 1 Comments
    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?

    • 8 Comments
    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?

    • 20 Comments
    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?

    • 6 Comments
    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?

    • 2 Comments
    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++?

    • 2 Comments
    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?

    • 39 Comments
    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?

    • 42 Comments
    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?

    • 0 Comments
    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?

    • 1 Comments
    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?

    • 37 Comments
    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?

    • 5 Comments
    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?

    • 27 Comments
    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?

    • 27 Comments
    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?

    • 39 Comments
    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

    • 203 Comments
    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 (141 items) «23456