0

I am working on a module to create event in google calendar so i want to make the json file but please tell me about the following problem. How can i give value to email of EmailAddress Class? My View Model Class is:

public class CreateJson
    {
        public EventTime end { get; set; }
        public EventTime start { get; set; }
        public string summary { get; set; }
        public List<EmailAddress> attendees { get; set; }
    }

    public class EventTime
    {
        public string dateTime { get; set; }
        public string timeZone { get; set; }
    }

    public class EmailAddress
    {
        public string email { get; set; }
    }


My Controller Class:
 CreateJson objCreateJson = new CreateJson()
            {
                summary = summary,
                end = new EventTime()
                {
                    dateTime =endtime,
                    timeZone = "America/Los_Angeles"
                },
                start = new EventTime()
                {
                    dateTime = starttime,
                    timeZone = "America/Los_Angeles"
                },
                attendees =
                {
                   ???????
                }
            };

How can i give value to email of EmailAddress Class?

1 Answer 1

2

Use collection initializer syntax:

attendees = new List<EmailAddress>()
{
    new EmailAddress(...),
    new EmailAddress(...),
    new EmailAddress(...),
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.