S
Siegfried Heintze
The program below works when compiling it with VS2008. However, when I try to
compile it from the command line I get this error:
props.cs(38,53): error CS0246: The type or namespace name 'List' could not
be found (are you missing a using directive or an assembly reference?)
props.cs(38,66): error CS1925: Cannot initialize object of type
'List<Person>' with a collection initializer
I was hoping I could go to online help and find the dll I need to reference
but no luck!
How do I determine the DLL for a given package? What would be the command to
compile this from the command line?
Incidently, do I need to buy VS2008 to compile simple programs like this or
is the compiler included in the .NET framework that I can download for free?
Thanks,
Siegfried
/**
* Begin commands to execute this file using MS.NET with CMD.EXE
* csc /outrops.exe /checked /d:noprompt /debug props.cs
* props
* del props.exe
* del props.pdb
* End commands to execute this file using MS.NET with CMD.EXE
*/
using System;
using System.Runtime.InteropServices;
class Person {
public Person() { }
public string name { get; set; }
}
class Parent : Person {
public System.Collections.Generic.List<Person> children;
}
public class props {
[DllImport("msvcrt.dll", SetLastError = true)]
static extern int _getch();
static System.IO.TextWriter outp = System.Console.Out;
static System.IO.TextReader inp = System.Console.In;
public static void Main(string[] args){
try{
Person p = new Person { name = "sieglinde" };
outp.WriteLine(p.name);
Parent siegfried = new Parent { children= new List<Person> { new
Person{name="sieglinde"} }, name="siegfried"};
} finally {
#if noprompt
outp.WriteLine("terminating props.cs");
#else
outp.Write("Enter any key to exit props.cs: ");
_getch();
#endif
}
}
}
compile it from the command line I get this error:
props.cs(38,53): error CS0246: The type or namespace name 'List' could not
be found (are you missing a using directive or an assembly reference?)
props.cs(38,66): error CS1925: Cannot initialize object of type
'List<Person>' with a collection initializer
I was hoping I could go to online help and find the dll I need to reference
but no luck!
How do I determine the DLL for a given package? What would be the command to
compile this from the command line?
Incidently, do I need to buy VS2008 to compile simple programs like this or
is the compiler included in the .NET framework that I can download for free?
Thanks,
Siegfried
/**
* Begin commands to execute this file using MS.NET with CMD.EXE
* csc /outrops.exe /checked /d:noprompt /debug props.cs
* props
* del props.exe
* del props.pdb
* End commands to execute this file using MS.NET with CMD.EXE
*/
using System;
using System.Runtime.InteropServices;
class Person {
public Person() { }
public string name { get; set; }
}
class Parent : Person {
public System.Collections.Generic.List<Person> children;
}
public class props {
[DllImport("msvcrt.dll", SetLastError = true)]
static extern int _getch();
static System.IO.TextWriter outp = System.Console.Out;
static System.IO.TextReader inp = System.Console.In;
public static void Main(string[] args){
try{
Person p = new Person { name = "sieglinde" };
outp.WriteLine(p.name);
Parent siegfried = new Parent { children= new List<Person> { new
Person{name="sieglinde"} }, name="siegfried"};
} finally {
#if noprompt
outp.WriteLine("terminating props.cs");
#else
outp.Write("Enter any key to exit props.cs: ");
_getch();
#endif
}
}
}