Can we make our own List<string, string, string> in C#.NET? I need to make a list having 3 different strings as a single element in the list.
Can we make our own List<string, string, string> in C#.NET? I need to make
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can certainly create your own class called
Listwith three generic type parameters. I would strongly discourage you from doing so though. It would confuse the heck out of anyone using your code.Instead, either use
List<Tuple<string, string, string>>(if you’re using .NET 4, anyway) or (preferrably) create your own class to encapsulate those three strings in a meaningful way, then useList<YourNewClass>.Creating your own class will make it much clearer when you’re writing and reading the code – by giving names to the three different strings involved, everyone will know what they’re meant to mean. You can also give more behaviour to the class as and when you need to.