I have a List
object.
How can I pass these list values to separate strings? The strings always occur in the same position as follows:
[0] = time
[1] = location
[2] = note
So I need a time, location, and note string for these values.
driver.location开发者_如何转开发 = log.event_data[1];
It says cannot implicitly convert to string.
Your question is unclear but it seems like the answer is
string time = list[0];
string location = list[1];
string note = list[2];
assuming that your "list" is a List<string>
named list
.
If your list is called 'list' then you can just do the following
string time = list[0];
string location = list[1];
string note = list[2];
Do you want to use classes or structures? Here's an example:
public class SomeClass {
public string Time { get; set; }
public string Location { get; set; }
public string Note { get; set; }
}
Though you probably shouldn't use the string
type to store these values, either.
If this wasn't what you meant, can you please rephrase a bit?
If they always appear in the same location, you should be able to use the SubString() function to parse the data out, assuming it's all in one string. Is it an array? a string, or what?
精彩评论