function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
viswsanathviswsanath 

What kind of situation we are using these Condtion

HI All,

PFB Condtion, i have totaly confuise on this two condtion , What kind of situation we are using on this  two condtion,so any one  please explain me.  

Public Class list<account> acc {get;set;}
public List<Account> accts = new List<Account>();

Regards,
viswa
 
Best Answer chosen by viswsanath
pconpcon
Can you please expand on what you are asking?  The first is exposing a list of accounts and a public get and set method.  The other is initializing a lsit of accounts.

All Answers

pconpcon
Can you please expand on what you are asking?  The first is exposing a list of accounts and a public get and set method.  The other is initializing a lsit of accounts.
This was selected as the best answer
AshlekhAshlekh
Hi,

The first line which you have written is wrong think you want to write this.
 
Public class Xcontroller
{
   Public  list<account> acc {get;set;} 
   /* the set get is saying that you can use this list on page and sat value from page and you need to initialize the         
​     list in some where in code before using in page as I've initialize in  constructor 
   */
  
  public List<Account> accts = new List<Account>(); 
  /*
    The above line is saying that you have declared a list of Account which is referenced by accts and you have initialize when class is loaded and member of class created.
    but you have not defined it's setter/getter so you cann't user accts on page.    

    public Xcontroller()
    {
        acc = new  list<account>();
    }


}

-Thanks
Ashlekh Gera