Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How can I read string value and store it in a array using data reader
- string[] result = null;
- while (reader.Read())
- {
- result = Convert.ToString[](reader["RoleID"]);
- }
- reader.Close();
- var results = new List<string>();
- while (reader.Read())
- {
- results.Add(reader["RoleID"].ToString());
- }
- // results now holds all of the RoleID values in the reader
- string check = "something";
- if (results.Any(item => item.Equals(check)))
- {
- // results contains the value in check
- }
- // or use all items that equal check
- foreach (var item in results.Where(obj => obj.Equals(check))
- {
- // do something with each item that equals check
- }
- var result= new ArrayList();
- while (reader.Read())
- {
- result.Add(Convert.ToString[](reader["RoleID"]));
- }reader.Close();
- var results = new List<string>();
- while( reader.Read() ){
- results.Add(reader["RoleID"].ToString());
- }
- foreach(var result in results) {
- if(result == "check") {
- // do something
- }
- }
Add Comment
Please, Sign In to add comment