Tangara G

Tangara G

  • NA
  • 298
  • 90.2k

why not using new when creating an instance ?

Nov 13 2016 10:04 PM
Dear experts,
 
I have this question which is probably very easy for most of you but it beats me cos I am used to Java way of creating a new instance by doing like this :
 
Category c = new Category();
 
However, I come across the below code where I am not sure why it is written this way :
 
public class PurchaseOrderBL
{
 
UniEntities db = new UniEntities();
 
int purchaseOrderId;
 
Category category;
 
My question is why not Category category = new Category(); ?
 
Here's the Category class:
 
public class Category
{
private int categoryId{
get { return categoryId; }
set { categoryId = value; }
}
 
 
 
 
 
 
 
 
 
 

Answers (3)