Click to See Complete Forum and Search --> : delegate type inside a method


john_avi
February 9th, 2009, 11:11 PM
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?

cilu
February 10th, 2009, 01:19 AM
You can use anonymous delegates (C# 2.0) and lambda expressions (C# 3.0). For types you can use anonymous types (C# 3.0).

boudino
February 10th, 2009, 07:58 AM
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.