You need to sign in to do that
Don't have an account?

how to set default value
i hwant to set default value below is code
but its give error,
"Compile Error: expecting right curly bracket, found '[' at line"
[DefaultValue('Not Available')]
public String CompanyName{get; set;}
I've never seen that default value syntax before, at am not sure of whether or not it's supported. Have you tried setting the default value in the class constructor instead?
Agreed with Shaliesh,
you can declare like below
public final String str= 'India'; // I have assigned India to str variable
{
public String ETag {get; set;}
public String Id{get; set;}
public Link[] Links{get; set;}
Public String Address{get; set;}
Public AddressParsed AddressParsed{get; set;}
public String City{get; set;}
public String YearEstablished{get; set;}
public string BusinessStatus {get; set;}
// [DefaultValue('Not Available')]
public String CompanyName{get; set;}
/* public String CompanyName
{
get
{
CompanyName = 'Not Available';
return CompanyName;
}
set
{
// if(CompanyName == null)
// {
// CompanyName = 'Not Available';
// }
// else
// {
//CompanyName = CompanyName;
//}
}
}*/
public String FirstName{get; set;}
public String LastName{get; set;}
public Location Location{get; set;}
public String Phone{get; set;}
public String PostalCode{get; set;}
public String Website{get; set;}
public String StateProvince{get; set;}
public c_Contact[] Contacts{get; set;}
public String Neighborhood{get; set;}
public Integer CorporateEmployeesSizeActual{get; set;}
public String CorporateEmployeesSizeRange{get; set;}
//public Integer CorporateSalesVolumeActual{get; set;}
public Decimal CorporateSalesVolumeActual{get; set;}
public String CorporateSalesVolumeRange{get; set;}
public String County{get; set;}
public String CreditRatingScore{get; set;}
public String EIN1{get; set;}
public String EIN2{get; set;}
public String EIN3{get; set;}
public String Fax{get; set;}
public String Gender{get; set;}
public Integer LocationEmployeesSizeActual{get; set;}
public String LocationEmployeesSizeRange{get; set;}
public Naics[] NaicsList{get; set;}
public String PrimaryNaics{get; set;}
public String PrimaryNaicsDescription{get; set;}
public String PrimarySic{get; set;}
public String PrimarySicDescription{get; set;}
public Sic[] SicList{get; set;}
public String Title{get; set;}
public String TollFree{get; set;}
public UriCls[] UriList{get; set;}
public String ZipPlus4{get; set;}
public String BusinessType{get; set;}
//Additional Property for Companies API
public String Franchise{get; set;}
public String LocationSalesVolumeActual{get; set;}
public String LocationSalesVolumeRange{get; set;}
public String TickerSymbol{get; set;}
//Additional Property for Match API
public String RuleName{get; set;}
public Integer Score{get; set;}
public String IsHomeBusiness{get; set;}
public EmailVendor emailVendor {get; set;}
public Company()
{
this.Links = new List<Link>();
this.CompanyName = 'Not Available';
this.CreditRatingScore = 'Not Available';
this.TickerSymbol = 'Not Available';
}
}
above is my code i assign value in constructor but its not work.
i want to dispaly default value if there is null value.
if company doest have any value then its display 'Not Available'.