Xarzu Posted August 18, 2012 Posted August 18, 2012 C# Split String Is Not Working ====================== Please Help. I wrote a C# program that reads code one line at a time. Each line has data seperated by tabs. Here is what my C# code is supposed to do. The line is supposed to be split into a string array by using the "Split" string methodIt is supposed to be spit read in text one line at a time and I use the "Split" method to group the line according to the tab character. But, as this screen shot shows, it does not work. Any idea why?
mkreku Posted August 19, 2012 Posted August 19, 2012 It may be a syntax problem. Maybe try something like: string[] arr = line.Split(new char [] {'\t'}); Swedes, go to: Spel2, for the latest game reviews in swedish!
Nightshape Posted August 20, 2012 Posted August 20, 2012 Go go mkreku, I thought you couldn't code. 1 I came up with Crate 3.0 technology. Crate 4.0 - we shall just have to wait and see.Down and out on the Solomani RimNow the Spinward Marches don't look so GRIM!
Malcador Posted August 20, 2012 Posted August 20, 2012 Are you sure it's tabs in the string and not spaces ? Why has elegance found so little following? Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - Edsger Wybe Dijkstra
Nightshape Posted August 21, 2012 Posted August 21, 2012 Are you sure it's tabs in the string and not spaces ? It's a matter of being certain what the delimiter should be, t, or n or a symbol. I tend to use a symbol so I can be explicit. I came up with Crate 3.0 technology. Crate 4.0 - we shall just have to wait and see.Down and out on the Solomani RimNow the Spinward Marches don't look so GRIM!
Humodour Posted August 21, 2012 Posted August 21, 2012 Please Help. I wrote a C# program I found your problem.
Prosper Posted August 23, 2012 Posted August 23, 2012 Show us line. All in your editor see if you can set a view of hex for the line string so we can be sure of all the characters. redacted
Prosper Posted August 23, 2012 Posted August 23, 2012 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LineSplit { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { richTextBox1.Clear(); string inputLine = textBox1.Text; string[] lines = inputLine.Split('\t'); foreach(string line in lines) { richTextBox1.AppendText("\n"); // skips a line richTextBox1.AppendText(line); } } private void button2_Click(object sender, EventArgs e) { textBox1.Text += '\t'; } } } http://i.imgur.com/fBhiu.png Works for me. Are you using mono? redacted
Nightshape Posted August 24, 2012 Posted August 24, 2012 Please Help. I wrote a C# program I found your problem. You're not still evangelising Python, hell next you'll tell me you think Javascript is awesome. C++ or fail dude. I came up with Crate 3.0 technology. Crate 4.0 - we shall just have to wait and see.Down and out on the Solomani RimNow the Spinward Marches don't look so GRIM!
Malcador Posted August 24, 2012 Posted August 24, 2012 Language snobbery is so undergrad. Still though, really should get back practicing my C++ and C#. 1 Why has elegance found so little following? Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - Edsger Wybe Dijkstra
Humodour Posted August 27, 2012 Posted August 27, 2012 (edited) Please Help. I wrote a C# program I found your problem. You're not still evangelising Python, hell next you'll tell me you think Javascript is awesome. C++ or fail dude. Eh, go away. Nobody takes you seriously anyway. Still, you accidentally stumbled upon a grain of wisdom. "C++ or fail" indeed. In this case the OP chose fail. P.S. Javascript is pretty annoying, but maybe if you try Coffeescript you'll still be a douchebag, but at least you'll be a douchebag using a nice language. What, are you going to tell me people should code interactive websites in C++? lol Language snobbery is so undergrad. Still though, really should get back practicing my C++ and C#. And yet it's what Ph.Ds and industry veterans will often spend their time writing papers on. In this case, Microsoft themselves have rapidly ditched C# in favour of a return C++ for the cases where they were using it (which were cases where they used C++ originally anyway - turns out C# isn't a suitable replacement). This is poignant because Microsoft are the ones who designed C# in the first place, and for this main purpose (to replace C++ internally). Anybody still using C# in light of this is just unaware of better languages for their needs - C++ and Python for instance, depending on the solution required. Edited August 27, 2012 by Krezack
Malcador Posted August 27, 2012 Posted August 27, 2012 They spend their time sneering at other languages ? Wonder if the guy fixed his problem though, which was getting this function to work as intended. Why has elegance found so little following? Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - Edsger Wybe Dijkstra
Janmanden Posted August 28, 2012 Posted August 28, 2012 Lots of ideas here. That's what he asked for. Maybe the reason why the split doesn't work is because those four options are getting along so well, that they just don't want to be split.. Maybe they are currently discussing what ruleset they should use for their next adventure.. I suggest making a check for tabs before trying to split a string based on that. Make a regular expression and check to see if there any tabs in there or possible multiple spaces and apply the split based on what the result is. Could be tabs, could be spaces.. could it be love? 1 (Signatures: disabled)
J.Burke Posted September 12, 2012 Posted September 12, 2012 Oh hi, code talk. https://twitter.com/IridiumGameDev Ex-Obsidian Senior Programmer
Roby Atadero Posted September 14, 2012 Posted September 14, 2012 False alarm Burke, everyone left... Twitter: @robyatadero
Humodour Posted September 14, 2012 Posted September 14, 2012 What languages does Obsidian use? Just LUA and C++?
DABhand Posted September 14, 2012 Posted September 14, 2012 Please Help. I wrote a C# program I found your problem. You're not still evangelising Python, hell next you'll tell me you think Javascript is awesome. C++ or fail dude. >Insinuating C++ is the king of all languages >2012 Yeah I know no green text here. I could equally say to you ASM or fail dude. But I am sure that you may lie about knowing ASM fully just like your claim to invent the crate 3.0 technology which is car engine tech, which wasn't invented by a Swedish man, just sayin'
Roby Atadero Posted September 15, 2012 Posted September 15, 2012 What languages does Obsidian use? Just LUA and C++? The games that have used Onyx consist of this: The engine is C++. Our tools are a combination of C++ and C# (all of our development is done using Windows machines). And our UI utilizes Actionscript (Flash). I cannot say exactly what other languages besides C++ the projects before DS3 used but, the primary language of all of our released games has been C++. Twitter: @robyatadero
J.Burke Posted September 18, 2012 Posted September 18, 2012 Alpha protocol was made using Unreal, so we used C++ and unreal script. Fallout New Vegas was made using Gambryo -- programmers worked almost exclusively in C++ (including tools work), though some XML work was required for UI. Roby already went into Onyx projects. https://twitter.com/IridiumGameDev Ex-Obsidian Senior Programmer
lingmaaki Posted September 25, 2012 Posted September 25, 2012 Check this one string str = null; string[] strArr = null; int count = 0; str = "CSharp split test"; char[] splitchar = { ' ' }; strArr = str.Split(splitchar); for (count = 0; count < = strArr.Length - 1; count++) { MessageBox.Show(strArr[count]); } http://csharp.net-informations.com/string/csharp-string-split.htm maaki.
Prosper Posted September 26, 2012 Posted September 26, 2012 Dear persons who posted here, Why I should work for you: Your CEO seems cool. Your developers are passionate (a big plus) I enjoy Obsidian's CV. I enjoy C++. I have never had a job, so I would know best what it feels like to be off task. I am a decent 3D artist. This includes sculpting characters , extruding faces, adding edge loops, and texturing, rigging, animating the result. 1 redacted
Nightshape Posted October 11, 2012 Posted October 11, 2012 (edited) Please Help. I wrote a C# program I found your problem. You're not still evangelising Python, hell next you'll tell me you think Javascript is awesome. C++ or fail dude. >Insinuating C++ is the king of all languages >2012 Yeah I know no green text here. I could equally say to you ASM or fail dude. But I am sure that you may lie about knowing ASM fully just like your claim to invent the crate 3.0 technology which is car engine tech, which wasn't invented by a Swedish man, just sayin' *sigh* ... Really... Nice try. Edited October 11, 2012 by Nightshape I came up with Crate 3.0 technology. Crate 4.0 - we shall just have to wait and see.Down and out on the Solomani RimNow the Spinward Marches don't look so GRIM!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now