Search results
Top results related to why are dictionaries a generic namespace in c#?
Top Answer
Answered Jan 09, 2019 · 10 votes
I think your misconception is that you believe that aliasing automatically imports the types of a namespace.
using Fourth.Fifth.Sixth;-
makes all types in this namespace visible without additional qualification.
using MyAlias = First.Second.Third;-
does nothing besides giving the namespace a new name, without importing it. So, if you change using First.Second.Third; into using MyAlias = First.Second.Third; the ambiguity is removed because Thing from First.Second.Third is no longer visible without further qualification. But obviously the other using is still importing Thing from Fourth.Fifth.Sixth.
Also see the corresponding definitions in the C# 5.0 Language Specification:
A using-alias-directive (§9.4.1) introduces an alias for a namespace or type.
A using-namespace-directive (§9.4.2) imports the type members of a namespace.
1/5
Top Answer
Answered Feb 08, 2011 · 45 votes
Most likely, you are only configuring the Release build, not actually building the project in Release mode.
Simply select "Release" mode from the drop down box in the toolbar, as shown in pic below:
or you can do the same thing from your project's Properties:
Then when you will build the project (Ctrl+Shift+B), it will build in Release mode and place the output in the folder you have configured in Project properties. (Usually this is bin/release.)
If you still don't see files in the release folder then as suggested by Gishu in the comments, check the Output Window while the build is in progress to see where the binaries are actually being created.
2/5
Top Answer
Answered Mar 07, 2013 · 6 votes
i saw a class have the following method: anotherClass.something.methodName(arguments);
The method is not from the class anotherClass instead it is from the class of object something.
The class anotherClass has a field/property something which is of another class type, that class has the method methodName
3/5
Top Answer
Answered Jun 10, 2009 · 42 votes
Anders Hejlsberg: (C# lead architect)
There are several reasons. One is performance. We can observe that as people write code in Java, they forget to mark their methods final. Therefore, those methods are virtual. Because they're virtual, they don't perform as well. There's just performance overhead associated with being a virtual method. That's one issue.
A more important issue is versioning. There are two schools of thought about virtual methods. The academic school of thought says, "Everything should be virtual, because I might want to override it someday." The pragmatic school of thought, which comes from building real applications that run in the real world, says, "We've got to be real careful about what we make virtual."
When we make something virtual in a platform, we're making an awful lot of promises about how it evolves in the future. For a non-virtual method, we promise that when you call this method, x and y will happen. When we publish a virtual method in an API, we not only promise that when you call this method, x and y will happen. We also promise that when you override this method, we will call it in this particular sequence with regard to these other ones and the state will be in this and that invariant.
Every time you say virtual in an API, you are creating a call back hook. As an OS or API framework designer, you've got to be real careful about that. You don't want users overriding and hooking at any arbitrary point in an API, because you cannot necessarily make those promises. And people may not fully understand the promises they are making when they make something virtual.
4/5
Top Answer
Answered May 08, 2015 · 4 votes
If you are writing generic method, then it should have generic parameter
public static int CountList<T>(List<T> list){ int listcount = 0;- for (int i = 0; i < list.Count; i++) listcount++; return listcount;}
Then you can call it with any generic list
var list = new List<AnyDataType>();// ..Foo.CountList(list);-
Same goes to classes. If you want to parametrize class with some generic type, you should provide generic argument
public class Foo<T>-
As @DStanley stated, you don't need to parametrize individual methods in that case
public class Foo<T>{ public static int CountList(List<T> list) { int listcount = 0; for (int i = 0; i < list.Count; i++) listcount++; return listcount; } }
But you need to parametrize class
Foo<int>.CountList(list)-
Suggested reading: Generics (C# Programming Guide)
5/5
stackoverflow.com › questions › 78510478Can regular python packages contain namespace packages?
stackoverflow.com › questions › 7851047811 hours ago · In the above example, "foo" is a regular package and "foo/bar" is a namespace package. I assume that the answer should be "no" since "foo" would have 2 different roles, but I could be wrong. (A reason for this question would be if foo/__init__.py is in extensive use, and converting it to a namespace package would cause a major headache.) python.
Searches related to Why are dictionaries a generic namespace in C#?