CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2010
    Location
    .Net 4.0
    Posts
    58

    Separating line by blank spaces

    Hello,

    I have a list of values in the following format:

    Code:
        A12     BC3   4D   5.678  9.123      45
        E67    FG89  12H  34.567  8.912       3
    I would like to be able to create objects with the name in the first column (i.e, A12 or E67) and have each object contain indexable/searchable attributes from the second and fourth columns (i.e., A12.BC3 = 5.678 & E67.FG89 = 34.567). However, I'm not very good at objects.

    Right now I have the following code to try to separate the entries:

    Code:
     using (StreamReader sr = new StreamReader(fs))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        manip = line.Split(' ');
                        foreach (string aline in manip)
                        {
                            bool hasvalue = CheckForEntry(aline);
                            if (hasvalue == true)
                            {
                                Console.WriteLine("The next entry is {0}", aline);
                                Console.ReadLine();
                                counter++;
                                //resets counter
                                if (counter == 6)
                                {
                                    counter = 1;
                                }
                                if (counter == 1)
                                {
                                    residuename = aline;
                                    Residue residuename = new Residue(); //how to do this correctly??
                                }
                            }
                        }
                    }
                }
    Code:
    public class Residue
                public class Atom
            {
                {
                    public float Shift {get; set;}
                    public Shift(float shift)
                    {
                        Shift = shift;
                    }
                }
            }
    One of my problems is that I'm trying to create a new Residue class called whatever "aline" happens to be at the time and the way I'm doing it now is obviously wrong. Another problem is that my compiler says that public Shift (float shift) must have a return type. Could someone please help me out?

    Thanks!
    Last edited by Danja91; June 15th, 2010 at 04:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured