Monday, 15 June 2015

Abstraction in OOPS C#

Abstraction: Abstraction is to hiding the complexity of object and showing the essential features of that object. It focus on what object can do instead of how it can do.
"Abstraction is to hiding the working style of an object and showing the information of an object as understandable manner"

Real world example of Abstraction:

Suppose we take example of Mobile phones.

Nokia 2710 (Features: Calling, SMS)
Nokia 3110 (Features: Calling, SMS, FM Radio, MP3, Camera)


Abstract information(All mobile phones makes a call to any number and can send SMS)

for that you have to make a abstract class:

abstract class MobilePhone
    {
        public void Calling();
        public void SendSMS();
    }

public class Nokia2710 : MobilePhone
    {
        public void FMRadio();
        public void MP3();
        public void Camera();
    }

    public class Nokia3110 : MobilePhone
    {
        public void FMRadio();
        public void MP3();
        public void Camera();
        public void Recording();
        public void ReadAndSendEmails();
    }

Introduction to object oriented programing in C#

Class: A class is a blue print of an object that contains members and functions in it.

for ex:

class A
{
int a;
string s;
public void int sum(int a, int b
{
}
}

Object:An object is a instance of a class. You can create object of a class and access all the public variable and methods of that class.

for ex:

A objA=new Obj A();
int sum=a.sum(a,b);

Tuesday, 26 May 2015

What is Xaml?

XAML stands for extensible Application markup language, is variant of xml describing GUI. In winforms GUI framework was created in same language that you would use for interacting with the GUI like vb.net or c#.net.

Sunday, 10 May 2015

Hello World in WPF- WPF Tutorial

In xaml:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="60">Hello World</TextBlock>
    </Grid>
</Window>

After run program





For more info visit:
http://webxperts.co.in/


Loop throuth all textboxes in Winforms

For iterating through all textboxes in winforms:

foreach (TextBox TextBox in this.Controls.OfType<TextBox>())
            {
                if (TextBox.BackColor == Brushes.Green)
                {
                    //your code
                }
            }

Sunday, 22 March 2015

Design Patterns:Three layred or Tiered architechture

This article will provide you the basic knowledge of Layered architecture.

3 tier architecture
What is layer- A layer is a reusable code that can be used any where, in any project.
in .net a layer is setup as a project.
We can have multiple layers to segregate our project.
We are going to discuss three layered architecture here. in three layered architecture we have three layers:
1.Data Access Layer
2.Business Logic Layer
3.Presentation Logic Layer

1.Data Access Layer(DAL)- Data access layer is basically used to interact with database. We use ado.net to access database in this layer. BAL layer interact with DAL to interact with database. BAL call DAL function to send and receive data to database.

2.Business Access Layer(BAL)-BAL layer is basically used to define business logic, calculations, conversions and all the stuff that is required by Presentation Layer.

3.Presentation Logic Layer- This layer is basically used for user interface. Presentation layer always interact to BAL layer for any data required or to send any data to database.

Benifits of layered architecture:
1.Easy to maintain of code. Because all layers are seperated from other so we can change to any layer easyily.
2.Reusability of code: We can use the code anywhere in the same project or any other project using reference.
3.Provide a segregated architecutre.

Sunday, 15 February 2015

Ineterface with example in C#

Interface Definition: An interface is basically a contract or service which will implemented by other classes.
This implements the rules which will forced to use by derived classes.
Interface has only declarations of methods and properties. They do not have body in method they
have only the signatures.
Declaring Interfaces:

public interface IUser
{
void AddUser(User user);
void EditUser(int Id)
User GetUserByID(int Id);
}
Implementation:

public class User:IUser
{
public User GetUserByID(int Id)
{
 var context=...................;
var user=context.Users.find(Id);
return user;
}
public EditUser(int Id)
{
var context=...................;
var user=context.Users.find(Id);
context.Entry(user).State=EntityState.Modified;
context.SaveChanges();
}
public void AddUser(User user)
{
var context=...................;
context.Users.Add(user);
context.SaveChanges();
}
}