There are many namespaces in C# for example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
I know System namespace eliminates need to have System name in every WriteLine() method. I wish to know is there any technique to decide appropriate name space for a program. Is there any articles about this?
Loading

VulpesRank #55 · 29.2K reputationPosted Dec 4, 2011, 5:02 AM EST
Posted Dec 4, 2011, 5:49 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Dec 4, 2011, 11:53 AM EST
Posted Dec 4, 2011, 12:06 PM EST
VulpesRank #55 · 29.2K reputationPosted Dec 4, 2011, 12:12 PM EST
If you just want to know what namespace a framework type belongs to then, as Sam, says you need to consult the MSDN documentation. This will also tell you what dll it's in, in case you need to add a reference to that dll as well as a 'using' directive for the namespace.
Sam HobbsRank #107 · 20.5K reputationPosted Dec 4, 2011, 4:10 PM EST
Namespace: System
Posted Dec 4, 2011, 6:07 PM EST
using System;
using System.Collections.ObjectModel;
Suppose I have to write this program from scratch how to decide what are the namespaces I have to use.
using System;
using System.Collections.ObjectModel;
class ConverterCollection
{
private Converter
public ConverterCollection(Converter
{
this.convert = convert;
}
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, convert(item));
}
}
public class MainClass
{
public static void Main()
{
ConverterCollection
delegate(string s) { return s.ToUpper(); });
c.Add("Hello");
c.Add("World!");
foreach (string s in c)
Console.WriteLine(s);
}
}
Sam HobbsRank #107 · 20.5K reputationPosted Dec 4, 2011, 6:18 PM EST
VulpesRank #55 · 29.2K reputationPosted Dec 4, 2011, 11:41 PM EST
http://msdn.microsoft.com/en-us/library/ms132397.aspx
To be able to write a C# program in a reasonable amount of time, you need to have a familiarity with the C# language itself and at least the basic framework namespaces and classes. Armed with that knowledge, you can usually find anything else you may need from the documentation (or by googling) as types which have related functionality tend to be grouped in the same namespace.
Satish BhatRank #2,496 · 563 reputationPosted Dec 5, 2011, 2:02 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 5, 2011, 6:28 AM EST
I didn't know that and I'm sure it will be useful to Maha :)
Posted Dec 5, 2011, 7:22 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 5, 2011, 10:24 AM EST
Posted Dec 5, 2011, 11:40 AM EST
public class Example
{
public static void Main()
{
BigInteger[] values = { 2, 100, BigInteger.Pow(2, 64) };
foreach (var value in values)
Console.WriteLine(Math.Exp(BigInteger.Log(value) / 2));
}
}
VulpesRank #55 · 29.2K reputationPosted Dec 5, 2011, 12:55 PM EST
The program should then build and run.
Sam HobbsRank #107 · 20.5K reputationPosted Dec 5, 2011, 1:09 PM EST