You need to sign in to do that
Don't have an account?
vamshi krishna 255
dml requires sobject
public class contact
{
public string lastname;
}
contact cc =new contact();
cc.lastname='damu';
insert cc;
{
public string lastname;
}
contact cc =new contact();
cc.lastname='damu';
insert cc;
Greetings!
You do not need to create the Strinng Variable since the LastName is the field of Contact Object and you can directly assign value as below:
Reference:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_insert_update.htm
Also,I would suggest you to use the Class name differently as there is an existing Object which is named as Contact.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri