Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
AnswerRe: counting in c# Pin
Richard MacCutchan20-May-13 3:10
mveRichard MacCutchan20-May-13 3:10 
GeneralRe: counting in c# Pin
MKS Khalid20-May-13 8:32
MKS Khalid20-May-13 8:32 
AnswerRe: counting in c# Pin
Abhinav S20-May-13 5:13
Abhinav S20-May-13 5:13 
Questionnested for Pin
MKS Khalid19-May-13 21:42
MKS Khalid19-May-13 21:42 
AnswerRe: nested for Pin
Richard MacCutchan19-May-13 21:55
mveRichard MacCutchan19-May-13 21:55 
AnswerRe: nested for Pin
Keith Barrow19-May-13 22:46
professionalKeith Barrow19-May-13 22:46 
AnswerRe: nested for Pin
Abhinav S20-May-13 0:36
Abhinav S20-May-13 0:36 
QuestionC# Assignment Pin
Member 1006323419-May-13 9:14
Member 1006323419-May-13 9:14 
I have this assignment:

Develop a C# console application that implements three arrays; a string array initialized with exactly the following five data items { "Widget 15.50", "Thingy 50.99", "Ratchet25.00", "Clanger115.49", "Fracker75.25" }, a string array to hold the five part names to be parsed from the previously detailed string array, an array of five double value prices to be parsed from the previously mentioned array.
Create a void method that will accept as arguments the two arrays of strings and the array of doubles when called from Main. In the method you will access the five members of the first string array mentioned above and you will parse out the name portion of each string element (first 7 bytes), assigning the string value to the corresponding element in the array of names. In the method you will also parse out the numeric portion of each string and assign it to the corresponding element of the price array. The parsing should be done using the string method SubString.
In Main, after calling the parsing method you will display the elements of both the array of names and the array of prices side-by-side (do not display the array from which you parsed the data items).
The output should look something like this:
Widget $15.50
Thingy $50.99
Ratchet $25.00
Clanger $115.49
Fracker $75.25
Press any key to continue . . .

This is what I have so far and I have an error and I don't know what is wrong:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] combo = { "Widget 15.50", "Thingy 50.99", "Ratchet25.00", "Clanger115.49", "Fracker75.25" };
            string name = Convert.ToChar(combo[].Substring(0, 7));
            double price = Convert.ToInt32(combo[].Substring(7, 12));;

            parse(ref combo, ref name, ref price);


        }

        static void parse(ref string[] combo, ref string name, ref double price)
        {
            for (int x = 0; x < combo.Length; x++)
            {
                Console.Write(name + price + "\n");
            }


        }
   }
}

It gives me a syntax error for lines for 14 and 15.


modified 19-May-13 15:23pm.

AnswerRe: C# Assignment - Repost Pin
Richard MacCutchan19-May-13 9:36
mveRichard MacCutchan19-May-13 9:36 
GeneralRe: C# Assignment - Repost Pin
Member 1006323419-May-13 9:37
Member 1006323419-May-13 9:37 
GeneralRe: C# Assignment - Repost Pin
Richard MacCutchan19-May-13 9:46
mveRichard MacCutchan19-May-13 9:46 
GeneralRe: C# Assignment - Repost Pin
Member 1006323419-May-13 9:49
Member 1006323419-May-13 9:49 
AnswerRe: C# Assignment Pin
NotPolitcallyCorrect19-May-13 10:16
NotPolitcallyCorrect19-May-13 10:16 
GeneralRe: C# Assignment Pin
Member 1006323419-May-13 10:26
Member 1006323419-May-13 10:26 
GeneralRe: C# Assignment Pin
NotPolitcallyCorrect19-May-13 10:38
NotPolitcallyCorrect19-May-13 10:38 
GeneralRe: C# Assignment Pin
Member 1006323419-May-13 10:57
Member 1006323419-May-13 10:57 
AnswerRe: C# Assignment Pin
OriginalGriff19-May-13 19:04
mveOriginalGriff19-May-13 19:04 
GeneralRe: C# Assignment Pin
N8tiv20-May-13 7:52
N8tiv20-May-13 7:52 
Questionchat client/client Pin
baharan2019-May-13 8:52
baharan2019-May-13 8:52 
AnswerRe: chat client/client Pin
Dave Kreskowiak19-May-13 16:40
mveDave Kreskowiak19-May-13 16:40 
AnswerRe: chat client/client Pin
Abhinav S19-May-13 18:22
Abhinav S19-May-13 18:22 
QuestionC# Help Pin
Member 1006323419-May-13 8:24
Member 1006323419-May-13 8:24 
GeneralRe: C# Help Pin
harold aptroot19-May-13 8:36
harold aptroot19-May-13 8:36 
GeneralRe: C# Help Pin
Member 1006323419-May-13 8:40
Member 1006323419-May-13 8:40 
GeneralRe: C# Help Pin
harold aptroot19-May-13 8:52
harold aptroot19-May-13 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.