I am relatively new in C#, but have several years C++/Java. I am writing
a little C# console app to "test the waters" and learn the language.
If I have a class defined as:
class MyClass
{
MyClass(string s1, int i2, bool b3)
{
}
}
Why can't I declare a variable on the stack somewhere later on in my
code like this:
// .... code above
MyClass mc("Hello",42, true);
Do I always have to alloc from the heap when instantiating objects whose
ctor have parameters?
a little C# console app to "test the waters" and learn the language.
If I have a class defined as:
class MyClass
{
MyClass(string s1, int i2, bool b3)
{
}
}
Why can't I declare a variable on the stack somewhere later on in my
code like this:
// .... code above
MyClass mc("Hello",42, true);
Do I always have to alloc from the heap when instantiating objects whose
ctor have parameters?
Comment