What is the difference between a.Equals(b) and a ==
b?
Answer1:
a=b is used for assigning the values (rather then
comparison) and a==b is for comparison.
Answer2:
a == b is used to compare the references of two objects
a.Equals(b) is used to compare two objects
Answer3:
A equals b -> copies contents of b to a
a == b -> checks if a is equal to b
Answer4:
Equals method compares both type and value of the
variable, while == compares value.
int a = 0;
bool b = 0
if(a.Equals(b))
Answer5:
a.Equals(b) checks whether the Type of a is equal to b
or not! Put it in another way,
Dim a As Integer = 1
Dim b As Single = 1
a.Equals(b) returns false. The Equals method returns a
boolean value.
a == b is a simple assignment statement.
Answer6:
a.equals(b) will check whether the “b” has same type as
“a” has and also has the same data as “a” has.
a==b will do the same thing.
if you have done this in c++ under “operator
overloading” than you guys must be aware of this sytaxts.
they are doing the same thing there is only sytaxtical
difference.
let me explain it in different manner.
a==b : means compare “b” with “a”. always left hand side
expression evaluated first so here in this case “a”
(considered an object) will call the overloaded operator
“=” which defines “Equals(object)” method in it’s class.
thus, ultimately a.equals(b) goanna called.
so the answer is: both will perform the same task. they
are different by syntaxt
Answer7:
Difference b/w a==b,a.Equals(b)
a.Equals(b):
The default implementation of Equals supports reference
equality only, but derived classes can override this
method to support value equality.
For reference types, equality is defined as object
equality; that is, whether the references refer to the
same object. For value types, equality is defined as
bitwise equality
== :
For predefined value types, the equality operator (==)
returns true if the values of its operands are equal,
false otherwise. For reference types other than string,
== returns true if its two operands refer to the same
object. For the string type, == compares the values of
the strings.
How would one do a deep copy in .NET?
Answer1:
System.Array.CopyTo() - Deep copies an Array
Answer2:
How would one do a deep copy in .NET?
The First Approach.
1.Create a new instance.
2.Copy the properties from source instance to newly
created instance.
[Use reflection if you want to write a common method to
achive this]
The Second Approach.
1. Serialize the object and deserialize the output.
: Use binary serialization if you want private variables
to be copied.
: Use xml Serialization if you dont want private
variable to be copied.
What is boxing?
Boxing is an implicit conversion of a value type to the
type object
int i = 123; // A value type
Object box = i // Boxing
Unboxing is an explicit conversion from the type object
to a value type
int i = 123; // A value type object box = i; // Boxing
int j = (int)box; // Unboxing
Is string a value type or a reference type?
Answer1:
String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum ,
float, int, long, sbyte, short,strut, uint, ulong,
ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object,
string
Reference types are stored in the Heap
Answer2:
Yes String is reference type. C# gives two types of
variable reference and value type. string and object are
reference type.
How does the lifecycle of Windows services differ from
Standard EXE?
Windows services lifecycle is managed by “Service
Control Manager” which is responsible for starting and
stopping the service and the applications do not have a
user interface or produce any visual output, but
“Standard executable” doesn’t require Control Manager
and is directly related to the visual output
What’s wrong with a line like this?
DateTime.Parse(myString)
the result returned by this function is not assigned to
anything, should be something like varx =
DateTime.Parse(myString)
NET is Compile Time OR RunTime Environment?
.Net’s framework has CLS,CTS and CLR.CTS checks
declartion of types at the time when u write code and
CLS defines some rules and restrictions.and CLR comile
everything at runtime with following benefits: Vastly
simplified development Seamless integration of code
written in various languages Evidence-based security
with code identity Assembly-based deployment that
eliminates DLL Hell Side-by-side versioning of reusable
components Code reuse through implementation inheritance
Automatic object lifetime management Self describing
objects
Describe the role of inetinfo.exe, aspnet_isapi.dll
andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running,
handling ASP.NET requests among other things.When an
ASP.NET request is received (usually a file with .aspx
extension),the ISAPI filter aspnet_isapi.dll takes care
of it by passing the request tothe actual worker process
aspnet_wp.exe.
What’s the difference between Response.Write()
andResponse.Output.Write()?
The latter one allows you to write formattedoutput.
What methods are fired during the page load?
Init() - when the pageis
instantiated, Load() - when the page is loaded into
server memory,PreRender()
- the brief moment before the page is displayed to the
user asHTML, Unload()
- when page finishes loading.
Where does the Web page belong in the .NET Framework
class hierarchy?
System.Web.UI.Page
Where do you store the information about the user’s
locale?
System.Web.UI.Page.Culture
What’s the difference between Codebehind="MyCode.aspx.cs"
andSrc="MyCode.aspx.cs"?
CodeBehind is relevant to Visual Studio.NET only.
What’s a bubbled event?
When you have a complex control, like DataGrid, writing
an event processing routine for each object (cell,
button, row, etc.) is quite tedious. The controls can
bubble up their event handlers, allowing the main
DataGrid event handler to take care of its constituents.
Suppose you want a certain ASP.NET function executed on
MouseOver overa certain button. Where do you add an
event handler?
It’s the Attributesproperty,
the Add function inside that property. So
btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
A simple”Javascript:ClientCode();” in the button control
of the .aspx page will attach the handler (javascript
function)to the onmouseover event.
What data type does the RangeValidator control support?
Integer,String and Date.
Page Numbers :
1
2
3
4
5