locked
error in accessing public class properties RRS feed

  • Question

  • User1259588416 posted

    I have a code below  where i m decalring a class  and i m getting error  when i m tring to use tht class properties

    public class Class1
    {
        public Class1()
        {
            //
            // TODO: Add constructor logic here;                

        }
        public class RCExtRequest
        {
            public Caller Mycaller;

        }
        public class Caller
        {
            
            public string vendorNameField;
            public string vendorpasswordField;
          
            public string VendorName
            {
                get
                {
                    return this.vendorNameField;
                }
                set
                {
                    this.vendorNameField = value;
                }
            }

            public string VendorPassword
            {
                get
                {
                    return this.vendorpasswordField;
                }
                set
                {
                    this.vendorpasswordField = value;
                }
            }

    }

    Now in another asp.net page on button click i m writing this code

    //Button click

    Class1.Caller cls = new Class1.Caller();
    Class1.RCExtRequest rcq = new Class1.RCExtRequest();
     rcq.Mycaller.VendorName = "vaccount96";    // getting error   -  Object reference not set to an instance of an object.
     rcq.Mycaller.VendorPassword = "goose6black5";

          
            Kindly help ...

    Tuesday, October 8, 2013 4:48 AM

Answers

  • User839260933 posted

    Hi Please try this code

    Class1.Caller cls = new Class1.Caller();
    cls.VendorName = "vaccount96"; 
    cls.VendorPassword = "goose6black5";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 8, 2013 5:20 AM

All replies

  • User839260933 posted

    Hi Please try this code

    Class1.Caller cls = new Class1.Caller();
    cls.VendorName = "vaccount96"; 
    cls.VendorPassword = "goose6black5";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 8, 2013 5:20 AM
  • User1259588416 posted

    Thank you it is working now

    Tuesday, October 8, 2013 5:22 AM