Newbie needs help in C#

  • Thread starter Thread starter p988
  • Start date Start date
P

p988

In a C# sample code it has the following beginning lines:

using System;
using System.Reflection
[assembly:AssemblyKeyFile ("Keyfile.snk")]
[assembly:AssemblyVersion ("1.0.0.0")]


What's the "keyfile.snk" file and how to generate it? What happens if the
code is compiled like this and the exe is distributed, should the .snk file
be distributed together?

What if the line: [assembly:AssemblyVersion ("1.0.0.0")] is not there? Will
a default version number be generated for this exe?


A book says that:"Remember, you create objects, but you never delete them;
the garbage collector deletes them for you."

What if I just code like following:

class File
{
protected:
int Handle; // File handle

public:
File (char* name)
{
// TODO: Open the file and copy the handle to Handle
}

~File ()
{
// TODO: Close the file handle
}
};


File* pFile = new File ("Readme.txt");
....
delete pFile;

Is "delete pFile" really not going to trigger the destructor, ~File() or
not? If not, why had the author put one there?
 
p988 said:
In a C# sample code it has the following beginning lines:

using System;
using System.Reflection
[assembly:AssemblyKeyFile ("Keyfile.snk")]
[assembly:AssemblyVersion ("1.0.0.0")]


What's the "keyfile.snk" file and how to generate it? What happens if the
code is compiled like this and the exe is distributed, should the .snk file
be distributed together?

The keyfile.snk file is generated by the Strong Name utility, sn.exe, which
is part of the Framework SDK. The compiler will use it to sign the assembly,
and you shouldn't distribute the .snk file.
What if the line: [assembly:AssemblyVersion ("1.0.0.0")] is not there? Will
a default version number be generated for this exe?

It will use a default version number of 0.0.0.0 if you don't specify a
version number.
A book says that:"Remember, you create objects, but you never delete them;
the garbage collector deletes them for you."

What if I just code like following:

(snipped)

That isn't C# code, it's C++. C# doesn't have a "delete" keyword.
 
Back
Top