Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created one class
as below



C#
public class clsCustomer
{
    private string strcustomername = "";
    private string strcustomercode = "";
    private string strcity = "";
    public string CustomerName
    {
        set
        {

            strcustomername=value;
        }
        get
        {
            return strcustomername;
        }

    }

  public string CustomerCode
    {
        set
        {

            strcustomercode=value;
        }
        get
        {
            return strcustomercode;
        }
    }
    public string City
    {
        set
        {

            strcity=value;
        }
        get
        {
            return strcity;
        }

    }
    public clsOrder[] Orders = null;
}
class clsOrder
{
    private string strProductname;
    public string ProductName
    {
        set
        {

            strProductname=value;
        }
        get
        {
            return strProductname;
        }
    }
}
class clsLINQ
{
      clsCustomer[] objcustomer=new clsCustomer[]
     {
         new clsCustomer(CustomerName="Khadak",CustomerCode="001",City="Ludhiana",
             Orders=new clsOrder[]
             (new clsOrder(ProductName="Shirt"),
              new clsOrder(ProductName="Socks"))),
          new clsCustomer(CustomerName="DEV",CustomerCode="002",City="Ludhiana",
                 Orders=new clsOrder[]
                (new clsOrder(ProductName="Shirt"))),
          new clsCustomer(CustomerName="AWE",CustomerCode="003",City="Ludhiana",
                    Orders=new clsOrder[]
                   (new clsOrder(ProductName="Socks")))

     }};



but getting an error

in clsLINQ error is "CustomerName doesnot exist in current context". same for customercode and city and Orders

pls tell regards
Posted
Updated 13-Sep-13 18:20pm
v2
Comments
m@dhu 13-Sep-13 5:03am    
Check the first item you are adding to the array "objcustomer.CustomerName" - "CustomerName"
shivani 2013 14-Sep-13 0:21am    
its not working

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900