Partial classes give you the ability to split a class into more than one source code .cs file.
If a class becomes particularly long and intricate you might decide to break it into pieces as shown below
//This file is stored in the Product.cs
public partial class Product
{
private string name;
private decimal price1;
public string Name
{
}
public decimal Price
{
}
public string ImageUrl
{
}
}
public partial class Product
{
//continued code here
}
these two partial classes comprise one class Product and are divided to simplify coding.
If a class becomes particularly long and intricate you might decide to break it into pieces as shown below
//This file is stored in the Product.cs
public partial class Product
{
private string name;
private decimal price1;
public string Name
{
}
public decimal Price
{
}
public string ImageUrl
{
}
}
public partial class Product
{
//continued code here
}
these two partial classes comprise one class Product and are divided to simplify coding.
This comment has been removed by the author.
ReplyDeletehey don't you think that with such kind of programming, the code will actually be scattered and debugging or finding the exact declarations/definitions will get more tedious ??
ReplyDeleteThese two partial classes are stored in two different .cs files ...So it will simplify the coding.
ReplyDeleteSo the first partial class will be stored for example in Product1.cs and the second partial class will be stored in Product2.cs.