Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3945178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:59:17+00:00 2026-05-20T00:59:17+00:00

I am using c# I have got below string in my variable. string results

  • 0

I am using c#

I have got below string in my variable.

string results = "Mr,Mike,Lewis,32,Project Manager,India";

Now I want to add these values in Dictionary type of session variable. I have declared a dict type variable in my code.

Dictionary<string, string> skywardsDetails = new Dictionary<string, string>();

Write now what I have written code was like below:

if (!string.IsNullOrEmpty(results))                                            
{                                                
    string[] array = results.Split(',');
    string title = array[0];
    string firstname = array[1];
    string lastname = array[2];
    string age = array[3];
    string designation = array[4];    
    string country = array[4];    

    //Here I want to write the new code which will add the results.Split(',') values in my Session variable as a Dictionary type.                                       

    foreach (string key in results.Split(','))
    {
    skywardsDetails.Add(key,//What to do here)
    }
}

Please suggest

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:59:18+00:00Added an answer on May 20, 2026 at 12:59 am

    Your CSV results variable doesn’t represent a dictionary. It represents an Employee model:

    public class Employee
    {
        public string Title { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
        public string Designation { get; set; }
        public string Country { get; set; }
    }
    

    and then:

    var tokens = (results ?? string.Empty).Split(',');
    if (tokens.Length > 5)
    {
        var employee = new Employee
        {
            Title = tokens[0],
            FirstName = tokens[1],
            LastName = tokens[2],
            Age = int.Parse(tokens[3]),
            Designation = tokens[4],
            Country = tokens[5]
        };
        // TODO: do something with this employee like adding it
        // to some dictionary, session, whatever
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VB.NET code. I have got the below string. http://localhost:3282/ISS/Training/SearchTrainerData.aspx Now I
I have got below string values in a variable. var mystring = '{img_src:/english/images/spa.jpg, img_title:Enjoy
I have got a variable which contains function hierarchy like: string str= fun1(fun2(),fun3(fun4(fun5(34,33,'aa'),'value',fun6())) //
I have got this error when using Enterprise Library 3.1 May 2007 version. We
I have just got a MacBook Pro and have been using it (+Fusion) to
I have got the following code from here to read an Excel file using
I've got two PostgreSQL databases that have been created using the same sql file.
i have got below code which is working fine: public abstract class Beverage {
I have a web project built in eclipse using Spring and for Tomcat. Before
I am using jquery for accordion menu, I have got a news box on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.