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 3664734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:40:48+00:00 2026-05-19T01:40:48+00:00

I have a little problem which I have no clue how to solve. I

  • 0

I have a little problem which I have no clue how to solve. I will give the who;e code from the class so you can see what its doing:

{

class CompetitorDataFile
{
    //collection of DataFileRecords - people
    public List<DataFileRecord> DataFileRecords;
    public string FileName = "";

    //called when DataFile created
    public CompetitorDataFile(string FileName)
    {
        //creates the collection
        DataFileRecords = new List<DataFileRecord>();
        this.FileName = FileName;
    }

    //fill DataFileRecords with stuff from text file
    public void ReadDataFile()
    {
        foreach (string s in File.ReadAllLines(FileName))
        {
            if (s == "") continue;
            DataFileRecord dfr = new DataFileRecord();
            dfr.Name = s.Split(',')[0];
            dfr.CPSA = s.Split(',')[1];
            dfr.PostCode = s.Split(',')[2];
            dfr.Rank = s.Split(',')[3];
            dfr.Score1 = s.Split(',')[4]; //new for score system
            dfr.Score2 = s.Split(',')[5]; //new for score system 
            dfr.Score3 = s.Split(',')[6]; //new for score system 
            dfr.Score4 = s.Split(',')[7]; //new for score system 
            dfr.Score5 = s.Split(',')[8]; //new for score system 
            dfr.Score6 = s.Split(',')[9]; //new for score system 
            dfr.Score7 = s.Split(',')[10]; //new for score system 
            dfr.Score8 = s.Split(',')[11]; //new for score system
            dfr.TotalSingleScore = s.Split(',')[12]; //new for score system
            DataFileRecords.Add(dfr);
        }
    }

    public int FindByCPSA(string CPSA)
    {
        //set index to 0
        int index = 0;
        //go through each record looking for CPSA number match
        foreach (DataFileRecord dfr in DataFileRecords)
        {
            if (dfr.CPSA.ToLower() == CPSA.ToLower())
            {
                //if it's found return the current index
                return index;
            }
            //increase index and move to next record
            index++;
        }
        //not found returning -1
        return -1;
    }

    //save DataFile records to text file
    public void SaveDataFile()
    {
        //delete backup file if found
        if (File.Exists(FileName+".bck")) 
            File.Delete(FileName+".bck");
        //make backup of existing
        if (File.Exists(FileName))
            File.Move(FileName, FileName + ".bck");
        //create a temporary array of string
        List<string> stringy = new List<string>(DataFileRecords.Count);
        //go through each DataFile record and create a single string line
        foreach (DataFileRecord dfr in DataFileRecords)
            stringy.Add(dfr.SingleString);
        //saves all strings to file
        File.WriteAllLines(FileName, stringy.ToArray());
    }
}

//a single record - one person
public class DataFileRecord
{
    public string Name;
    public string CPSA;
    public string PostCode;
    public string Rank;
    public string Score1; //new for score system
    public string Score2; //new for score system
    public string Score3; //new for score system
    public string Score4; //new for score system
    public string Score5; //new for score system
    public string Score6; //new for score system
    public string Score7; //new for score system
    public string Score8; //new for score system
    public Int64 TotalSingleScore; // used to get total score for one user

    public string SingleString
    {
        get
        {
            return string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", Name, CPSA, PostCode, Rank, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8); //,{4} and , Score are new for score system
        }
    }

    public string PoshSingleString
    {
        get
        {
            return string.Format("{0,-20}|{1,-10}|{2,-9}|{3,-9}|{4,2}|{5,2}|{6,2}|{7,2}|{8,2}|{9,2}|{10,2}|{11,2}", Name, CPSA, PostCode, Rank, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8);
            //return SingleString.Replace(",0", ""); //may be used to replace 0
            //return SingleString.Replace(",", ", ");
        }

I have a problem with this line of code

dfr.TotalSingleScore = s.Split(',')[12];

TotalSingleScore is the only int (all others are strings) as a result I get this error:
“Error 1 Cannot implicitly convert type ‘string’ to ‘long'”

How do I go about solving this? Code is C# and software is VS 2008 Pro

Thanks

  • 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-19T01:40:49+00:00Added an answer on May 19, 2026 at 1:40 am

    Since TotalSingleScore is declared as Int64, you have to use Int64.Parse.

    Sample: dfr.TotalSingleScore = Int64.Parse(s.Split(',')[12]);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Evening :) I have a little problem... As you can see in my code
i have little problem how i will recognize which item was clicked with OnClickEvent.
I have a little problem understanding how to create a child class's contructor, which
I have a little problem regarding arranging of code, which depends on each other
I have this little problem, that I cannot figure out which arguments to pass
I'm with a little problem. I have the container div for some elements which
I have little unusual problem to solve. I need some hint or links to
I have a little problem. This is my code: stackPanelShapesContainer = new StackPanel(); InitializeStackPanle();
i have a little problem with my java socket code. I'm writing an android
I have a little problem in object programming in javascript There is a class

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.