Is this function overloading

Today I was just playing through visual studio with certain classes and functions. I started writing a class with functions overloading mechanism. I wrote down class as;

And its consumer as;

When I executed the above piece I got the output as 5 and 6. ( I have skipped the printing part).
So here I have overloaded AddNumbers with 2 different signature.

Then a question came in my mind as if the function signature is same just a slight change in it's access modifier, will that be a function overloading?
I modified the above 2 signatures as;

I was under impression that a slight change in function signature means it is a function overloading. After compiling the modified piece, I got an error saying function definition already exist.
So I concluded that, difference in access modifier does not matter. To overload a function either it's return type or arguments should differ.


Layered and n-tier architecture


Layered architecture is a logical division of functional units. This is mainly used in enterprise applications to solve complex business scenarios.
Whereas tiered architecture is more of physical division of functional units.
To have a closer look following diagram will elaborate this.
 
Here a single layer can have multiple logical units like presentation layer, database layer etc. In tiered architecture these units represents physical entities like presentation server , database servers. These entities may or may not be a different computers, but in most enterprise applications for the scalability and maintenance these units are distributed.

Here is a sample layered application for reference.
 
 

How Partial class and constructor works

In this case first we will try to take a look at partial class. In the simple terms Partial classes are used when functionality is distributed. When the assembly is compiled, the partial classes gets combined together to form a single class unit. Have you ever thought what happens with the constructors, properties or methods for that matter.
Are these all also gets combined to form a single unit.
Let's take a look at this with simple partial class definition.



Now when this piece of code is compiled it will try to combine MyPartialClass into a single unit. When similar definitions for constructor and other functions are encountered compiler enters in ambiguity to decide which definition to be picked. It generates compile time error.
We cannot have similar constructor in partial classes. So is methods. Because at compile time partial classes gets combined to form one single unit so it created an ambiguity for constructors and methods.


Returning value from Method/Property is Risky

Value types are stored on Stack and reference types are stored on heap. Now here comes the twist as if a programmer by mistake or by intention returns a value from a method or property which is of type value it could lead to havoc.


Let’s take a look at this by an example;


After executing this program you will get the output as 0 instead of 4. This is because the property myNumber of class Arithmetics returns a copy of structure of type MyNumber and not reference type. If you replace the struct with class ypu will get result as 4 instead of 0, because in that case a reference will be passed.

What will be the impact of doing so?
If you call a method or access a property that returns a value-type object, do not modify it or call mutators (methods that modify its state or data) on it. You are dealing with a copy and any change you make does not affect the real instance.
Ref: .Net Gotchas

Aliases doesn’t work always

.Net CTS i.e. Common Type System have defined aliases for primitive data types. This facility is made available for the programmers who come from the programming languages prior to .Net like C++, VB6 etc.C3 makes use of int and long for 32 bit and 64 bit unassigned integer whereas VB makes use of Integer and long for the same.
Lets take a look at CTS memory allocation table for C# and C++;

CTS type
Size
C# alias
Type equivalent in C++
System.Int32
4 bytes
int
int or long
System.Int64
8 bytes
long
_ _int64
System.Char
2 bytes
char
WCHAR
System.Double
8 bytes
double
double

Now from the table above it is clear that C# makes use of int as an alias for 32 bit unassigned integer and C++ makes use of int or long. But long in case of C# is 64 bit unassigned integer.

Now you might ask what does that make difference. Let's have a look at it by an example.
We will call beep() function from an unmanaged code with its required arguments.
VB6 prototype is;
Beep(dwFreq as Long, dwDuration as Long) as Boolean
Now if we write it in .net, we might pass arguments as ;
Beep(long dwFreq,long dwDuration)
Now in this case long for VB is 32 bit unassigned integer and long for C# is 64 bit unassigned integer. The function will never return any output because of expected type mismatch.
If you are having any doubts about types in your mind, it is always a good practice to make use qualified names from CTS.

Ref: .Net Gotchas