| Back to Questions Page |
| |
| Question |
How do you remove the objects which are not in
use?Explicitly or implicitly?What is the exact mechanism
going behind? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions , Advanced Software Systems |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Dispose method()  |
| Venkat |
| |
| |
| Answer | Garbage collectors removes  |
| Raghu Sathish |
| |
| |
| Question |
Does c# supports destructors? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Yes
Example:
class A
{
A(){} //Constructor.
~A(){} //Distructor.
.........
..........
}  |
| K. Amith Kumar |
| |
| |
|
|
| |
| Answer | i think it doesnt allow to use Destructor.
there is a method called Dispose() which automatically
calls destructor  |
| Ashish Gupta |
| |
| |
| Answer | yes,C# allows destructor.  |
| 'tiger' Senthil |
| |
| |
| Answer | yes.
when a objects created by Constructor are removed by
destructor  |
| Vijay |
| |
| |
| Answer | Yes and No,
C# supports destructors just to provide a familiar way fo
destructing objects for C++ developers. even syntax also is
same but internally its the dicpose method that does all
the work.
Even if you declare a destructor the compiler automatically
translates a destructor into an override of the
Object.Finalize() method. In other words, the compiler
translates the following destructor:
class Class1
{
~Class1(){}
}
Into the following code:
class Class1
{
Protected override void Finalize()
{
try{..}
finally { base.Finalize();}
}
}
I guess that makes things more clear.  |
| Praveen Saxena |
| |
| |
| Answer | No, I didnt think distructor is supported by C# as far as
dispose() is concern it is used for clean up code like
finalize the object is distroyed automatically by garbage
collector  |
| Mahesh |
| |
| |
| Answer | Desturctors are very much supported by c#. Internally a c#
destructor is converted to a finalize method call.  |
| Puneet |
| |
| |
| Answer | yes c# allow destructures  |
| Kamlesh Sharma |
| |
| |
| Question |
what is a constructor? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Constructor is a method that is executed when an object is
created.  |
| Divya |
| |
| |
| Answer | Constructor is a method which will be executed when an
object is created. It is used to Intialize the
object.constructors has the same name as the class
name.constructors will take parameters.constructors doesnot
return any value  |
| Ranjith |
| |
| |
| Answer | constructor is a special type of method that invoke when u
create a new instance of a class. Basically it is used to
initialize the member variables.Its name must be same as
the class name.It have no return type.  |
| Dharmendra Nonia |
| |
| |
| Answer | It is very Important to know that
---------------------------------------
Constructor is generally used to create the new instance of
a class.
Constructor is special type of method that is used to
initialized the member variable and It has same name as the
class Name.It does not have return type.  |
| Shadab Alam |
| |
| |
| Question |
why instance? what are the uses of instance? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | The object of a class is called as Instance & the process is
called as Instantiation.
To access or to call a member of a class we need instance.
eg.
public class myClass
{
public myClass()
{
}
public string show()
{
return "Hello India!";
}
}
To access method show(), we need instance of the class
myClass. And the code will be as:-
myClass obj_mc = new myClass()
string str=obj_mc.show();
Now str contains string value 'Hello India!'
Hope u have got the point.  |
| Navin C. Pandit |
| |
| |
| Answer | instace is the way to access members(methods) in that
class,by this instance to invoke the methods.  |
| Yathirajulu |
| |
| |
| Question |
what are the advantages of c# over vb.net? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions , Hcl |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | C# Supports memory pointer where as VB.net dont
C# is Suitable for C,C++ Programmer
casting object type is easy in C# (object)
in vb.net Ctype(blah blah blah)  |
| Bond |
| |
| |
| Answer | c#.net is more secure when compare to vb.net
if any dout plz mail me  |
| Ssr |
| |
| |
| Answer | C# supports two things which is not supported by VB.NET
1. Operator Overloading
2. Pointer  |
| Nikhil |
| |
| |
| Answer | c# is case sencitive,vb.net is not case sencitive,c#
statements is placed between braces but in vb,net in
between end of itself(sub .. end sub).
thank you.  |
| Chandra |
| |
| |
| Answer | the gifference is C# works on pointers,overloading and also
it is more reliable and readable than VB  |
| Rajesh |
| |
| |
| Answer | C# supports two things which is not supported by VB.NET
1. Operator Overloading
2. Pointer  |
| Thirumoorthy |
| |
| |
| Question |
what is the difference between interface and abstraction? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Choice-Solutions |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1) In Interface we can give only declarations not
definitions but in abstraction we can hv definitions also.
2) In an Abstraction we must hv at least one abstract
function.
3) Abstraction can not be instantiate .
4) In Interfaces we can not assign access identifier.
5) A class can implement 2 interfaces but can inherit only
one Abstract function.  |
| Ashish Gupta |
| |
| |
| Answer | interface:
in interface,all methods must b abstract,by default all
members are PUBLIC,cant b implimented infact derived class
impliments its methods
interface can use multiple interface
abstract:
it is just like interface,not imolimented by itself,only
derived class can impliment abstract class or abstract
methods,abstract methods can b private unlike interface,cant
allow multiple inheritance  |
| Sajid |
| |
| |
| Answer | In Interface, all the member functions are abstract implicitly
so it is imp. to define all fn. declared inside Interface.
Moreover, we cann't define a fn. or we cann't declare any
member variable in an Interface. Also, we cann't declare or
define any non-abstract method in Interface.
In Abstract class, we can declare an abstract method as well
as we can also define a non-abstract method. We can also
declare a variable member in abstract class.
In both the condition, declared abstract method is
implemented out side the class i.e in derived class which
inherits Interface/Abstract class, whatever you have used.  |
| Navin C. Pandit |
| |
| |
| Question |
Can an Assembly have multiple versions |
Rank |
Answer Posted By |
|
Question Submitted By :: Krishna |
| This Interview Question Asked @ TCS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Yes  |
| Krishna |
| |
| |
| Answer | no  |
| Praveen |
| |
| |
| Answer | yes  |
| Xyz |
| |
| |
| Answer | YES  |
| Sudhir |
| |
| |
| Answer | yes  |
| Durgesh |
| |
| |
| Answer | Yes  |
| Diana Cheriyan |
| |
| |
| Answer | yes  |
| Vijaykumar |
| |
| |
| Answer | yea  |
| Vaibhav Patel |
| |
| |
| Answer | As an assembly have multiple versions. side by side
execution is the best example of this.  |
| Lakhan |
| |
| |
| Answer | yes  |
| Baburaj P V |
| |
| |
| Answer | Yes, DLLhell problem is solved with this side by side
execution.  |
| Chvramana |
| |
| |
| Answer | yes  |
| Chandan |
| |
| |
| Question |
Difference between C++ and C#.net |
Rank |
Answer Posted By |
|
Question Submitted By :: Krishna |
| This Interview Question Asked @ TCS , Wipro, Wipro |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | C# - web programming,CLR..  |
| Krishna |
| |
| |
| Answer | C++ is OOPS based while C# is Component & OOPS Based..  |
| Raghu Sathish |
| |
| |
| Answer | Default access Specifier is Public in c++.
Default access Specifier is Private in c#.net.  |
| Sivaraman.s |
| |
| |
| Answer | c++:
1. C++ code usually compiles to assembly language.
2. will allow multiple inheritence. eg. allows a method to
be overriden many times in subclasses (derived classes).
C#:
1. C# by contrast compiles to Intermediate language (IL),
which has some similarities to java byte code.
2. supports inheritence, but not multiple, only 1 override
per method/function/  |
| Suryaprakash |
| |
| |
| Answer | C++ is platform independent i.e. it directly compiles the
code into executable file where as C# is platform dependent
bcoz. it compiles the code to intermediate language(IL) &
the IL is the paased to .NET framework which activates CLR.
The CLR converts these IL into executable file.  |
| Navin C. Pandit |
| |
| |
| Answer | Navin, what you told is not correct. C++ is platform
dependent where as C# not. MSIL code will run in any
platform if CLR is running.
For e.g., if a CLR is developed for Linux(I think its
there), the code which got compiled in Windows can be run
there.
But for C++, the .exe file created is very much dependent
on the machine. For e.g., the Windows C++ .exe file can
never be run in Linux.  |
| Sharmin Jose |
| |
| |
| Answer | c++ follows oops and support for multiple inheritence with
direct executable file on platform whereas c# is oops and
component based .net lang.and compiles into assembly  |
| Vijay |
| |
| |
| Answer | c++ was older version while c# is obtained by merging features of c++ and java
 |
| Varun |
| |
| |
| Answer | 1.c++ supports Object oriented bt c# is purely object
oriented....2.in c++ the main class is diffrent it is
outside d class bt in c# the main class in inside d class..  |
| Aman |
| |
| |
| Answer | C++ uses the "include" header files where as c# uses the
namespaces,
C++ runs for assmebly languages
where as c# runs in .net framework,
Pointers can be used anywhere in c++
but in c# pointers are used only in unsafe mode.
C++ does not support the multiple inheritance,c# support
mulutiple inheritance.  |
| Basveshwar |
| |
| |
| Answer | C++ uses Object oriented concepts for their programming
where C# is pure object oriented language.One point that
support the above statement is
where as c++ supports multiple inheritance while C#
only single inheritance.
One feature of OOPs language is "Supporting Single
Inheritance"  |
| Rajesh |
| |
| |
| Answer | 1..the entry point in c++ is void main() whereas in c#
everything happens in a class.
2.c++ uses: as resolution operator whereas c#uses (.)period
as resolution operator.
3.in c++ to use a library it has to be reffered
explicitly.whereas in c# there is a namespace called
mscorlib.dll which implicitly load all the libraries  |
| Rupali |
| |
| |
| Answer | C# is a distinct language from C++. C++ is designed for
general object oriented programming in the days when the
typical computer was a standalone machine running a command
line-based user interface. C++ is a general-purpose
programming language with high-level and low-level
capabilities. It is a statically typed, free-form,
multi-paradigm, usually compiled language supporting
procedural programming, data abstraction, object-oriented
programming, and generic programming.
C++ is regarded as a mid-level language. This indicates that
C++ comprises a combination of both high-level and low-level
language features. C# is designed specifically to work with
the .Net and is geared to the modern environment of Windows
and mouse-controlled user interface, networks and the internet.
Microsoft has defined C# as follows
C# is a simple, modern, object oriented, and type-safe
programming language derived from C and C++. C# (pronounced
C sharp) is firmly planted in the C and C++ family tree of
languages, and will immediately be familiar to C and C++
programmers. C# aims to combine the high productivity of
Visual Basic and the raw power of C++.
However it is also undeniable that the two languages are
very similar in both their syntax and in that they are both
designed to facilitate the same paradigm of programming, in
which code is based around hierarchies of inherited classes.
Below I will briefly summarize the overall differences and
similarities between the two languages.
Environment
C++ was designed to be a low-level platform-neutral
object-oriented programming language. C# was designed to be
a somewhat higher-level component-oriented language. The
move to a managed environment represents a sea change in the
way you think about programming. C# is about letting go of
precise control, and letting the framework help you focus on
the big picture.
With the managed environment of .NET, you give up that level
of control. When you choose the type of your object, the
choice of where the object will be created is implicit.
Simple types (int, double, and long) are always created on
the stack (unless they are contained within other objects),
and classes are always created on the heap. You cannot
control where on the heap an object is created, you can't
get its address, and you can't pin it down in a particular
memory location. (There are ways around these restrictions,
but they take you out of the mainstream.)
The very structure of C# reflects the underlying framework.
There are no multiple inheritances and there are no
templates because multiple inheritances are terribly
difficult to implement efficiently in a managed,
garbage-collected environment, and because generics have not
been implemented in the framework.
Compile Target
C++ code usually compiles to assembly language. C# by
contrast compiles to Intermediate language (IL), which has
some similarities to java byte code. The IL is subsequently
converted to native executable code by a process of
Just-In-Time compilation. The emitted IL code is stored in a
file or a set of files known as an assembly. An assembly
essentially forms the unit, in which IL code id packaged,
corresponding to a DLL, or executable file that would be
created by C++ compiler.
Memory Management
C# is designed to free the developers from the task of doing
memory management. It means in C# you do not have to
explicitly delete memory that was allocated dynamically on
the heap, as you could in C++. Rather, the garbage collector
periodically cleans up memory that is no longer needed.
Lets have two C++ variable declarations
int j = 30;
Myclass *pMine=new Myclass
Here the contents of j are stored on the stack. This is
exactly that exists with C# value types. Our Myclass
instance is, however stored on the heap, and the pointer to
it is on the stack. This is basically the situation with C#
reference type, except that in C# the syntax dresses the
pointer up as a reference. The equivalent of C# is:
Int j=30;
Myclass mine=new Myclass()
This code has pretty much the same effect in terms of where
the objects are stored as does the above C++ code - the
difference is that Myclass is syntactically treated as a
reference rather then a pointer.
The big difference between C++ and C# is that C# doesn't
allow you to choose how to allocate memory for a particular
instance. For example, in C++ you wished to do this:
Int* pj=new int(30);
Myclass Mine;dfd
This will cause the int to be allocated on the heap, and the
Myclass instance to be allocated on the stack. You can't do
this in C# because C# deems that an int is a value type
while any class is always a reference type.
The other difference is that there is no equivalent to C++
delete operator in C#. Instead, with C#, the .Net garbage
collector periodically comes in and scans through the
refrences in your code in order to identify which areas of
the heap are currently in use by our program. It is then
automatically able to remove all the objects that are no
longer in use. This technique effectively saves you from
having to free up nay memory yourself on the heap.
Program Flow
Program flow is similar in C# to C++. In particular, the
following statements works exactly the same way as they do
in C++ and have the same syntax :
For, Return, Goto, Break, Continue
New in C# : for each
(1) If Else Condition
If statement works exactly the same way and has exactly the
same syntax in C# as in C++, apart from one point. The
condition in each if and else clause must evaluate to a
bool. For example, assuming x is an integer data types, not
a bool, the following C++ code would generate a compilation
error in C#.
if(x)
{ }
The correct syntax in C#
If(x != 0)
{ }
This shows that how additionally type safety in C# traps
error early.
While and do While
Int x;
While(x) //wrong
While(x != 0) //OK
Just as for if, these statements have exactly syntax and
purpose in C# as they do in C++, except that the condition
expression must evaluate to a bool.
(2) Switch
The switch statement serve the same purposes in C# as it
does in C++. It is however; more powerful in C# since you
can use a string as the test variables, something that is
not possible in C++.
In C# a switch statement may not "fall through" to the next
statement if it does any work. Thus, while the following is
legal in C++, it is not legal in C#:
switch (i)
{
case 4:
CallFuncOne();
case 5: // error, no fall through
CallSomeFunc();
}
To accomplish this, you need to use an explicit goto statement:
switch (i)
{
case 4:CallFuncOne();
goto case 5;
case 5:
CallSomeFunc();}
If the case statement does not work (has no code within it)
then you can fall
switch (i)
{
case 4: // fall through
case 5: // fall through
case 6:
CallSomeFunc();
}
(3) New control flow statement- for each
C# provides an additional flow control statement, for each.
For each loops across all items in array or collection
without requiring explicit specification of the indices.
Syntax:
Foreach(double someElement in MyArray)
{
Console.WriteLine(someElement);
}
(4) Boxing
In some cases you might wish to treat a value type as if it
was a reference type. This is achieved by a process know as
boxing.
Syntactically this just means casting the variable to an object.
Int j = 10;
Object boxobj = (object) j;
Boxing acts like any other cast, but you should be aware
that it means the contents of the variables will be copies
to the heap and a reference created.
The usual reason for boxing a value in order to pass it to a
method that expects a reference type as a parameter. You can
also unbox value, simply by casting it back to its original
type.
Int j = 10;
Object boxobj = (object) j;
Int k = (int) boxobj;
The process of unboxing will raise an exception if you
attempt to cast to the wrong type and no cast is available
for you to do the conversion.
(5) Structs
Structs are significantly different in C#. In C++ a struct
is exactly like a class, except that the default inheritance
and default access are public rather than private.
In C# structs are very different from classes. Structs in C#
are designed to encapsulate lightweight objects. They are
value types (not reference types), so they're passed by
value. In addition, they have limitations that do not apply
to classes. For example, they are sealed, which means they
cannot be derived from or have any base class other than
System.ValueType, which is derived from Object. Structs
cannot declare a default (parameter less) constructor.
(6) Value Types and reference types
C# distinguishes between value types and reference types.
Simple types (int, long, double, and so on) and structs are
value types, while all classes are reference types, as are
Objects. Value types hold their value on the stack, like
variables in C++, unless they are embedded within a
reference type. Reference type variables sit on the stack,
but they hold the address of an object on the heap, much
like pointers in C++. Value types are passed to methods by
value (a copy is made), while reference types are
effectively passed by reference.
(7) Classes
Classes in C# follow much the same principles as in C++,
though there are a few differences in both features and syntax.
Class MyClass : MyBaseClass
{
Private string SomeFiels;
Public in SomeMethod()
{
Return;
}
Classes defined in C# using what at first sight looks like
much the same syntax as in C++, but there are numerous
differences:
There is no access modifier on the name of the base class.
Inheritance is always public.
A class can only be derived from one base class. If no base
class is explicitly specified, then the class will
automatically be derived from System.Object, which will give
the class all the functionality of System.Object, the most
commnly used of which is ToString().
In C++, the only types of class members are variables,
functions, constructors, destructors and operator overloads,
C# also permits delegates, events and properties.
The access modifiers public, private and protected have the
same meaning as in C++ but there are two additional access
modifiers available:
i. Internal
ii. Protected internal
C++ requires a semicolon after the closing brace at the end
of a class definition. This is not required in C#.
(8) Destructors
C# implements a very different programming model for
destructors to C++. This is because the garbage collection
mechanism in C# implies that:
There is less need for destructors, since dynamically
allocated memory will get removed automatically.
Since it is not possible to predict when the garbage
collector will actually destroy a given object, if you do
supply a destructor for a class, it is not possible to
predict precisely when that destructor will be executed.
Because memory is cleaned up behind the scenes of C#, you
will find that only a small proportion of your classes
actually require destructors. C# has two-stage destruction
mechanism:
The class should derive from IDisposable interface and
implements Dispose () method.
The class should separately implements at destructor, which
is viewed as a reserve mechanism in case a client doesn't
need to call Dispose()
C# destructor looks, syntactically much like a C++
destructor, but it is totally
different. The C# destructor is simply a shortcut for
declaring a Finalize method that chain up to its base class.
Thus writing
~MyClass()
{
// do work here
}
is identical to writing
MyClass.Finalize()
{
// do work here
base.Finalize();
}
(9) Virtual methods must be explicitly overridden
In C# the programmer's decision to override a virtual method
must be made explicit with the override keyword.
To see why this is useful, assume that a Window class is
written by Company A, and that List Box and Radio Button
classes were written by programmers from Company B using a
purchased copy of the Company A Window class as a base. The
programmers in Company B have little or no control over the
design of the Window class, including future changes that
Company A might choose to make. Now suppose that one of the
programmers for Company B decides to add a Sort method to
ListBox:
public class ListBox : Window
{
public virtual void Sort(){"}
}
This presents no problems until Company A, the author of
Window, releases version 2 of its Window class. It turns out
that the programmers in Company A also added a Sort method
public class Window:
public class Window
{
// "
public virtual void Sort() {"}
}
In C++ the new virtual Sort method in Windows would now act
as a base method for the virtual Sort method in ListBox. The
compiler would call the Sort method in ListBox when you
intend to call the Sort in Window. In C# a virtual function
is always considered to be the root of virtual dispatch,
that is, once C# finds a virtual method, it looks no further
up the inheritance hierarchy If a new virtual Sort function
is introduced into Window the run-time behavior of ListBox
is unchanged. When ListBox is compiled again, however, the
compiler generates a warning:
"\class1.cs(54,24): warning CS0114: 'ListBox.Sort()' hides
inherited member 'Window.Sort()'.
To make the current member override that implementation, add
the override keyword. Otherwise add the new keyword.
To remove the warning, the programmer must indicate what he
intends. He can mark the ListBox Sort method new, to
indicate that it is not an override of the virtual method in
Window:
public class ListBox : Window
{
public new virtual void Sort(){"}
}
This action removes the warning. If, on the other hand, the
programmer does want to override the method in Window, he
need only use the override keyword to make that intention
explicit.
(10) C# requires definite assignment
C# requires definite assignment, which means that the local
variables, age, ID, and yearsServed must be initialized
before you call GetStats. This is unnecessarily cumbersome;
you're just using them to get values out of GetStats. To
address this problem, C# also provides the out keyword,
which indicates that you may pass in uninitialized variables
and they will be passed by reference. This is a way of
stating your intentions explicitly:
public class MyClass
{
public void GetStats(out int age, out int ID, out int
yearsServed) { }
}
Again, the calling method must match.
MyClass.GetStats(out age,out ID, out yearsServed);
(11) Boolean Values Conversion
There is no conversion between the bool type and other types
(specifically int).
C# Boolean values can not be treated as integer If you write
a code like this
if(BoolReturnFunction()) {}
and check if it returns zero it will evaluate false and
otherwise true
However using assignment versus equality is not allowed ,if
you write:
if( x = 4 ) {}
Where x is Boolean type variable, it will give you an
compile error
Constant value '4' cannot be converted to a 'bool'
If you write like this:
if(Convert.ToInt32(x)=4) {}
it will give you compilation error
Cannot implicitly convert type 'int' to 'bool'
(12) Exceptions
Exceptions are used in the same way in C# as in C++, apart
from the following two differences:
C# defines the finally block, which contains code that is
always executed at the end of try block irrespective of
whether any exception was thrown. The lack of this feature
in C++ has been a common cause of complaint among C++
developers. The finally block is executed as soon as control
leaves a catch or try block, and typically contains cleanup
code for resources allocated in the try block.
In C++, the class thrown in the exception may be any class.
C#, however, requires that the exception be a class derived
from System.Exception.
C++ syntax for catch:
Catch () {}
C# syntax for catch:
Catch { }
The full syntax fro try..catch..finally in C# looks like this
Try {}
Catch (MyException e) {}
Finally {}
(13) Delegates- Substitute of Pointer
C# does not support function pointers. However a similar
effect is achieved by wrapping references to methods in
special forms of class know as delegates.
A delegate is a class that can hold a reference to a method.
Unlike other classes, a delegate class has a signature, and
it can hold references only to methods that match its
signature. A delegate is thus equivalent to a type-safe
function pointer or a callback.
Delegates can be passed around between methods, and used to
call the methods to which they contains reference, in the
same way that function pointers can be in C++. Conceptually
delegates can be used in a similar way to an interface with
a single method. The main practical difference is that with
an interface the method name is fixed, whereas with a
delegate only the signature is fixed - the method name can
be different
// delegate declaration
delegate void MyDelegate(int i);
class Program
{
public static void Main()
{
TakesADelegate(new MyDelegate(DelegateFunction));
}
public static void TakesADelegate(MyDelegate SomeFunction)
{
SomeFunction(21);
}
public static void DelegateFunction(int i)
{
System.Console.WriteLine("Called by delegate with
number: {0}.", i)
}
}
Output: Called by delegate with number: 21.
(14) Properties
Most C++ programmers try to keep member variables private.
This data hiding promotes encapsulation and allows you to
change your implementation of the class without breaking the
interface your clients rely on. You typically want to allow
the client to get and possibly set the value of these
members, however, so C++ programmers create accessor methods
whose job is to modify the value of the private member
variables.
In C#, properties are first-class members of classes. To the
client, a property looks like a member variable, but to the
implementer of the class it looks like a method. This
arrangement is perfect; it allows you total encapsulation
and data hiding while giving your clients easy access to the
members.
Properties are defined with property declarations. The first
part of a property declaration resembles a field
declaration. The second part includes a Get accessor and/or
a Set accessor. In the example below, a class Employee
defines a property Age.
public class Employee
{
private static int age;
public int Age
{
get (return age);
set (age= value);
}
}
(15) Attributes and Metadata.
One significant difference between C# and C++ is that C#
provides inherent support for metadata: data about your
classes, objects, methods, and so forth. Attributes come in
two flavors: those that are supplied as part of the CLR and
attribute you create for your own purposes. CLR attributes
are used to support serialization, marshaling, and COM
interoperability. A search of the CLR reveals a great many
attributes. As you've seen, some attributes are applied to
an assembly, others to a class or interface. These are
called the attribute targets.
Attributes are applied to their target by placing them in
square brackets immediately before the target item.
Attributes may be combined, either by stacking one on top of
another.
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile(".\\keyFile.snk")]
or by separating the attributes with commas.
[assembly: AssemblyDelaySign(false),assembly:
AssemblyKeyFile (".\\keyFile.snk")]
Custom Attributes - Custom attributes are user-defined
attributes that provide additional information about program
elements. For example, you might define a custom security
attribute that specifies the permissions required by the
caller to execute a procedure.
[AttributeUsage(AttributeTargets.All)]
public class DeveloperAttribute : System.Attribute
{
private string name;
public DeveloperAttribute(string name)
{
this.name = name;
}
public virtual string Name
{
get (return name);
}
}  |
| Bm |
| |
| |
| Question |
If we add a textbox and give the required field
validator,and i add two radio buttons 1 is yes another one
is No.And i add another one server control button ,if i
click the button ,if the radio button Yes is checked the
validation control is fired ,if no the validation control
is not fired.So what you used to solve this problem. |
Rank |
Answer Posted By |
|
Question Submitted By :: Kamal |
| This Interview Question Asked @ CTS |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | required field valodator is used to check where a browser
has entered a value in atextbox or not.  |
| Vijay |
| |
| |
| Answer | Hi,
We can add the code in page_load
If Me.RadioButton1.Checked = True Then
Button1.CausesValidation = True
Else
If Me.RadioButton2.Checked = True Then
Me.Button1.CausesValidation = False
End If
End If  |
| Smriti |
| |
| |
| Answer | Required Field Validator does not depend upon any server
control either it is enable or disable.Means if radio
button1 is enable and radiobutton2 is disable at same time
then u press button then by default validation control
fired also in vice-versa case  |
| Prakash |
| |
| |
| Answer | Set causes validation on the button to false. Add a custom
javascript function to the onclick event of that button. In
the javascript function check whether the radio button is
checked or not then. If checked call ValidatorEnable
(regValidatorId, true) and then call Page_ClientValidate()
function.  |
| Vijay |
| |
| |
| Answer | Required validator checks for TextBox empty or not..
so to solve this problem
RequiredField validator--->properties..>validationGroup:sbmt
Button --->properties..>validationGroup:sbmt  |
| Ranga |
| |
| |
| Answer | Set both radio buttons AutoPostBack property to true.
and following code in page_load:
if (RadioButtonNo.Checked == true)
{
this.Button1.CausesValidation = false;
}
else
{
this.Button1.CausesValidation = true;
}  |
| Yogesh Sharma |
| |
| |
| Question |
What is the main difference between VS 2005 and VS 2003? |
Rank |
Answer Posted By |
|
Question Submitted By :: Kamal |
| This Interview Question Asked @ CTS , Satyam |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Please Read Atrical in
http://geekswithblogs.net/murraybgordon/archive/2006/02/03/6
8074.aspx
You will see diffrence.....  |
| Hiteshj78 |
| |
| |
| Answer | check this url
http://geekswithblogs.net/murraybgordon/archive/2006/02/03/6
8074.aspx  |
| Uppalashiva |
| |
| |
| Answer | There are components like DataGrid (2003) and GridView (2005).  |
| Dipak Salve |
| |
| |
| Question |
If i am expecting a single result from sqlserverdatabase
then what command should i follow ?sqlcommand.executereader
(commandbehaviour.singleresult)or sqlcommand.executescalar() |
Rank |
Answer Posted By |
|
Question Submitted By :: Pen2satya |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | sqlcommand.executescalar()  |
| Pankul |
| |
| |
| Answer | single result  |
| Raji |
| |
| |
| Answer | Sqlcommand.executescalar() is preffered.  |
| M.mohan Krishna |
| |
| |
| Answer | Both of these are same commandbehaviour.singleresult also
give you a single result. but we should use
sqlcommand.executescalar()  |
| Vinay |
| |
| |
| Question |
How do you install windows service? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Tech-Mahindra |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Go Through,It will help u guys alot
http://www.developerfusion.co.uk/show/3441/2/  |
| Smriti |
| |
| |
| Answer | hi..
First u have to create Windows Service..
For install Windows Service , u have to use one Command
first Build Windows Service..
then use this command..
installutil.exe <your service name.exe>
installutil.exe/u <your service name.exe> -->For uninstall
u have to use this command in visual studio 2005 -> visual
studio command Prompt -> write this above command..
Go in Particular path where u create Windows Service then
go to Bin -->Debug --> then implement this above Command..
try this..  |
| Nitya |
| |
| |
| Answer | I Think,For Installing Windoes Service
i)First Create new Project and in Right Side Expand Visual
C# and select windoes service.
ii)Give name to your service.
iii)Write Your code IN OnStart Event.
iv)Add New Project To Your Solution and select 'setup'
project which is in other project templates
v)and set Project output type to primary output which is in
FileSystem(Service Setup).
vi)Right click Your service Setup in solution Explorer And
click install then your service is install in your system
vii)Go to controlpanel And click Administrtivetools(make
sure u have login as a Administrator (or) you are part of
Administrative Group) and then click services.
viii)Go to your service name and right click it and click
start then your service will run  |
| N.v.s.prasad |
| |
| |
| Question |
what are the differences between windows services and web
services? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Tech-Mahindra |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | a windows service is installed on a Windows box and is very
windws platform dependent. it keeps running in the back
ground even if the user has logged off. a service is
typically use ful where on servers there are long running
processes.  |
| Varun |
| |
| |
| Answer | An XML Web service is a component that implements program
logic and provides functionality for diseparate
applications. These applications use standard protocols,
such as HTTP, XML, and SOAP, to access the functionality.
XML Web services use XML-based messaging to send and
receive data, which enables heterogeneous applications to
interoperate with each other. You can use XML Web services
to integrate applications that are written in different
programming languages and deployed on different platforms.
In addition, you can deploy XML Web services within an
intranet as well as on the Internet. While the Internet
brings users closer to organizations, XML Web services
allow organizations to integrate their applications.
A Windows service starts much before any user logs in to
the system (if it has been setup to start at boot up
process). A Windows service can also be setup in such a way
that it requires a user to start it manually ? the ultimate
customization!
Windows services run as background processes. These
applications do not have a user interface, which makes them
ideal for tasks that do not require any user interaction.
You can install a Windows service on any server or computer
that is running Windows 2000, Windows XP, or Windows NT.
You can also specify a Windows service to run in the
security context of a specific user account that is
different from the logged on user account or the default
computer account. For example, you can create a Windows
service to monitor performance counter data and react to
threshold values in a database.  |
| Smriti |
| |
| |
| Answer | Window services is a long running executable application
with is run in its own window session.Window services have
the ability to start when the computers boot and it can
manually handled.We can Manulay start,stop,pause window
services.
Webservices is a business logic Components which provide
functionalatily via internet.The funcanality provided by
Webservice can be used by any application irrespective of
the progamming langauge,Hardware platform and Operating
System on it is running.Webservice uses SOAP in ordr to
Expaose the Business Funcationality to world.  |
| Rajesh Kumar |
| |
| |
| Question |
In which conditions do you opt for Remoting services? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Tech-Mahindra , Manland |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | If client and server belongs to same operation system then
we have to go with remoting services..............  |
| Krishna |
| |
| |
| Answer | when the word iteranet comes in pic we should prifer 2 use
with condistion that saring with lot of pc  |
| Sisir |
| |
| |
| Answer | if the two systems are in dotnet platform  |
| Prasad |
| |
| |
| Answer | I don't know what Sisir is talking about... Remoting is
something like web services. You might decide to opt for
Remoting instead of web services in following cases...
1) Client and server platform is fixed
2) Protocol is NOT fixed. (Like web services strictly work
on HTTP protocol)
3) Where object serialization is to be done strictly
through CLR.
4) Where platform is fixed i.e. .Net framework.  |
| Maruti Tathe |
| |
| |
| Answer | when both the server and client r under our control then we
use .net remoting.  |
| Veera |
| |
| |
| Answer | Remoting can be prefered
1. Both server and Client sit in different machine.
2. Both server and client are .NET applications
3. The state of the objects transfered accross the network
should be maintained.
4. The objects of the IDictionary interface should be
transfered accross the network.  |
| Vaidyanathan R |
| |
| |
| Answer | Remoting can be used for .net to .net communication in
distributed environment  |
| Balavardhan Reddy |
| |
| |
| Answer | Remoting is used for .Net to .Net communication and in case
of Remoting we can use protocol other than
HTTP.Serialization in .Net remoting is handled by CLR
in .net Remoting.  |
| Amarjeet Singh |
| |
| |
| Question |
What are CCW and RCW? |
Rank |
Answer Posted By |
|
Question Submitted By :: Swapna |
| This Interview Question Asked @ Tech-Mahindra |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | These are business objects(Components).  |
| Manpreet Singh |
| |
| |
| Answer | ccw is called com callable wrapper where as rcw is called as
runtime callable wrapper.  |
| Prakash.rout |
| |
| |
| Answer | CCW is the Com Callable Wrapper. This will buily a bridge
between the Com Component and the .Net Component
RCW is the Runtime Callable Wrapper. This will built a
bridge between .Net Component and Com Component.converts
the .Net data type to Com Data type  |
| Sankar |
| |
| |
| Answer | RCW :- we are using COM Component in .Net application
directly we can't call. That's way we need to create a
wrapper trough Tlbimp.exe read COM classes and interface in
assembly metadata.  |
| Vijaya Bhaskar |
| |
| |
| Answer | Com Callable Wrapper
1)Create Assembly and compile with strong name.
2)Register Assembly using regasm <assembly name>
3)Register Assembly in GAC using gacutil /i <assembly name>
4)Use tlbexp <assemblyname.dll> to export Assembly as Type
Library for COM.
Runtime Callable Wrapper
1)Create Public Key Token file using sn.exe –k
<keyfilename.snk>
2)Use tlbimp <TypeLibFileName> /keyfile: <keyfilename.snk>
/out: <AssemblyName.dll>
3)Register Imported Assembly in GAC using gacutil /i
<AssemblyName.dll>  |
| Muruganantham |
| |
| |
| Answer | Com Callable Wrapper(ccw) build a bridge
between the Com Component and the .Net Component
Runtime Callable Wrapper(rcw) will built a
bridge between .Net Component and Com Component.converts
the .Net data type to Com Data type  |
| Abhishek Mishra |
| |
| |
|
| |
|
Back to Questions Page |