CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Location
    New Delhi
    Posts
    70

    delegate type inside a method

    Hi All,
    I am new to c# programming so sorry for asking a trivial question. I have a small query. I have read that "delegate type and ordinary types cannot be defined inside a method". I want to know what is the reason behind this.can anybody explain this to me?

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: delegate type inside a method

    You can use anonymous delegates (C# 2.0) and lambda expressions (C# 3.0). For types you can use anonymous types (C# 3.0).
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: delegate type inside a method

    Reason? It was designed this way. Maybe because it helps keep the grammar and the compiler simplier. Maybe be because it helps to obey minimal feature set which can be common for most of languages and platforms, in other words it is a way how to obey the CLS/CTS standards.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured