Value Type:
Value types are allocated on the stack just like primitive types in VBScript, VB6 and C/C++. Value
types are not instantiated using new go out of scope when the function they are defined within
returns.
Value types in the CLR are defined as types that derive from system.valueType.
A data type that fully describes a value by specifying the sequence of bits that constitutes the
value‘s representation. Type information for a value type instance is not stored with the instance
at run time, but it is available in metadata. Value type instances can be treated as objects using
boxing.
What is Boxing and unboxing ?
Boxing:
The conversion of a value type instance to an object, which implies that the instance will carry
full type information at run time and will be allocated in the heap. The Microsoft intermediate
language (MSIL) instruction set‘s box instruction converts a value type to an object by making a
copy of the value type and embedding it in a newly allocated object.
Un-Boxing:
The conversion of an object instance to a value type
What is JIT and how is works ?
An acronym for ”just-in-time,” a phrase that describes an action that is taken only when it becomes
necessary, such as just-in-time compilation or just-in-time object activation
What is portabLe executabLe (PE) ?
The file format used for executable programs and for files to be linked together to form executable
programs
What is strong name?
A name that consists of an assembly‘s identityHits simple text name, version number, and culture
information (if provided)Hstrengthened by a public key and a digital signature generated over the
assembly. Because the assembly manifest
contains file hashes for all the files that constitute the assembly implementation, it is
sufficient to generate the digital signature over just the one file in the assembly that contains
the assembly manifest. Assemblies with the same strong name are expected to be identical
What is gLobaL assembLy cache?
A machine-wide code cache that stores assemblies specifically installed to be shared by many
applications on the computer. Applications deployed in the global assembly cache must have a strong
name.
What is difference between constants, readonLy and, static ?
Constants: The value can’t be changed
Read-only: The value will be initialized only once from the constructor of the class. Static: Value
can be initialized once.
What is difference between shared and pubLic?
An assembly that can be referenced by more than one application. An assembly must be explicitly
built to be shared by giving it a cryptographically strong name.
What is namespace used for Loading assembLies at run time and name the methods?
System.Reflection
What are the types of authentication in .net?
We have three types of authentication:
1. Form authentication
2. Windows authentication
3. Passport
This has to be declared in web.config file.
What is the difference between a Struct and a CLass in C# ?
The struct type is suitable for representing lightweight objects such as Point, Rectangle, and
Color. Although it is possible to represent a point as a class, a struct is more efficient in some
scenarios. For example, if you declare an array of 1000 Point objects,
you will allocate additional memory for referencing each object. In this case, the struct is less
expensive.
When you create a struct object using the new operator, it gets created and the appropriate
constructor is called. Unlike classes, structs can be instantiated without using the new operator.
If you do not use new, the fields will remain unassigned and the object cannot be used until all of
the fields are initialized. It is an error to declare a default (parameterless) constructor for a
struct. A default constructor is always provided to initialize the struct members to their default
values.
It is an error to initialize an instance field in a struct.
There is no inheritance for structs as there is for classes. A struct cannot inherit from another
struct or class, and it cannot be the base of a class. Structs, however, inherit from the base
class Object. A struct can implement interfaces, and it does that exactly as classes do.
A struct is a value type, while a class is a reference type.
How big is the datatype int in .NET?
32 bits.
How big is the char?
16 bits (Unicode).
How do you initiate a string without escaping each backsLash?
Put an @ sign in front of the double-quoted string.
What’s the access level of the visibility type internal?
Current appLication.
Explain encapsulation ?
The impLementation is hidden, the interface is exposed.
What data type should you use if you want an 8-bit value that’s signed?
sbyte.
Speaking of Boolean data types, what’s different between C# and C/C++?
There‘s no conversion between 0 and faLse, as weLL as any other number and true, Like in
C/C++.
Where are the value-type variables allocated in the computer RAM?
Stack.
Where do the reference-type variables go in the RAM?
The references go on the stack, whiLe the objects themseLves go on the heap.
What is the difference between the value-type variables and reference-type variables in terms of
garbage collection?
The vaLue-type variabLes are not garbage-coLLected, they just faLL off the stack when they faLL
out of scope, the reference-type objects
are picked up by GC when their references go nuLL.
How do you convert a string into an integer in .NET?
Int32.Parse(string)
How do you box a primitive data type variable?
Assign it to the object, pass an object.
Why do you need to box a primitive variable?
To pass it by reference.
What’s the difference between Java and .NET garbage collectors?
Sun Left the impLementation of a specific garbage coLLector up to the JRE deveLoper, so their
performance varies wideLy, depending on whose JRE you‘re using. Microsoft standardized on their
garbage coLLection.
How do you enforce garbage collection in .NET?
System.GC.CoLLect();
Can you declare a C++ type destructor in C# like >MyClass()?
Yes, but what‘s the point, since it wiLL caLL FinaLize(), and FinaLize() has no guarantees when the
memory wiLL be cLeaned up, pLus, it introduces additionaL Load on the garbage coLLector.
What’s different about namespace declaration when comparing that to package declaration in Java?
No semicoLon.
No comments:
Post a Comment