|
Hey
how can i split a string into individual characters...
my input string is always a set of numbers like '15323' and i want to split it up and add all the numbers together so i end up with a total of 14 (from before).
Roman
|
|
|
|
|
You can use array syntax to iterate over the characters in a string, use int.TryParse to turn them into numbers, and add them. Something like this
string input = "12324590234"
int total = 0;
foreach(char c in input) // oh yeah, I reckon this will work, too
{
int next = 0;
if(int.TryParse(c.ToString(), out next))
{
total += next;
}
}
MessageBox.Show(next.ToString());
That's off the cuff, but it should be close.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
if you are building that string dynamically try to add a character like',' in between, so your string should be"1,2,3,4,5".
If your string is this way then we could easily convert it to an array using the split method...
example: string str1="1,2,3,4,5";
then str1.split(',')
....later you can use a for loop and add the elements in the array.....
Gautham
|
|
|
|
|
Hi,
char[] chars = "123456".ToCharArray();<br />
Robert
|
|
|
|
|
hi ,
hope the below codesnippet will satisfy your needs
string s ="123456";
int total=0;
for(int i =0 ; i <s.Length ;i++>
)
{
int m = Convert.ToInt32(s[i].ToString());
total += m;
}
Thanks
Saravanan R
|
|
|
|
|
|
I'm assuming that you are trolling.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You will fild lots of projects at codeproject.com, sourceforge.net, codeplex.com... Check them out
|
|
|
|
|
You got my "5" voting for that funny post!
Thanks!
|
|
|
|
|
I'm a worker in the UK.
I'll do you a deal. You do this stack of work that my boss wants me to get done and I'll send you a completed Project with all the documentation and code you require.
Russell
PS when 5 projects are "The most critical one" which do you start first?
|
|
|
|
|
Good Beta
My dear you should be ashamed of your behaviour. On one side you are using reference of Pakistan and on the other hand you are begging for a project. Pakistan is a country who has produced famous scientists and its engineers are working all over the world. But the idiot persons like you become the cause of embarrasment for them in the foreign countries. People like you tarnish the image of Pakistanis all over the world.
How hard is the final project to do? I think its nothing if you dare.
I am also a graduate from Pakistan. And i know how difficult it is to do final project.
Instead of begging for project and its source code, you should have only asked for the project ideas. But
AAP JAISAY BANDON MAIN ITNI TAQT KAHAN
Shame Shame Shame Shame Shame Shame Shame Shame Shame Shame Shame Shame for you
|
|
|
|
|
Hello All,
I want to connect to my oracle DB from my login control ,how can I do this???
Hello All,
I want to connect to my oracle DB from my login control ,how can I do this???
Nishu
|
|
|
|
|
Your UI layer shouldn't connect to any DB, you should have a business logic layer implimenting the action, and a data layer talking to the database. Connecting to Oracle is easy, google has tons of example code and info.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I want to connect my login control of ASP.NET 2.0 to oracle database...by default it is connect to the default sql server.....I wanto use my oracle DB for validation ....
nishu
|
|
|
|
|
Hi,
Connect to Oracle Database using ADODB.
first you need to add adodb in reference
and then:
ADODB.Connection objConnection = new ADODB.Connection();
if (objConnection.State == 1) objConnection.Close();
// If you are using network terminal
// ---------------------------------
objConnection.ConnectionString = "SERVER=SIDNAME; UID=USERNAME; PWD=PASSWORD;
" Driver={Microsoft ODBC for Oracle};"
// If you are working on Server
// ----------------------------
objConnection.ConnectionString = "UID=USERNAME; PWD=PASSWORD;
" Driver={Microsoft ODBC for Oracle};"
objConnection.Open("", "", "", -1);
Riaz
-- modified at 2:15 Wednesday 24th January, 2007
|
|
|
|
|
Is this for login contral????
nishu
|
|
|
|
|
Hey eveyone,
I recently found an application i made a while back, but i cannot find the source. I want to use it in my own program, preferrably in a panel in my program, or if that cannot happen a dialog would be fine. I need to be able to access some buttons, text boxes, labels, and a listview on the other program. If anybody thinks this is possible with minimal coding it would be a great help.
Thanks.
|
|
|
|
|
One option would be to reconstruct the source from the MSIL. There are a number of tools to do this although I've never tried them myself. Try this[^] Google search.
Steve
|
|
|
|
|
Yup, and you can also use application as library...
|
|
|
|
|
I am doing a database project using the TableAdapter. However, when I go to save using the Update() method, it does not appear in the intellisense and I get the error saying the TableAdapter does not contain a definition for Update(). Any help would be appreciated. Thank you.
-Fred Morstatter
|
|
|
|
|
Does the code compile/run ? Intellisense doesn't always work.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
No. It doesn't compile, it gives me an error saying that the method is undefined.
-Fred Morstatter
|
|
|
|
|
I am a beginner...i need to know how to write and read data in XML. Which is the data is use to create a graph...
|
|
|
|
|
You can just write it as a flat file, but if you want to interact with it using the DOM, use the XmlDocument class.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
Firstly add item->xml file and write the required details
For example:
<articlelist>
<id>1
<heading>Heading 1
etc.....
<by>Author1
<dated>January 05, 2007
<id>2
<heading>Heading 2
etc..etc....
<by>Author2
<dated>January 05, 2007
Now, to read this data the code would be as follows:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("path of the XML file")
XmlNodeList articleList = doc.SelectNodes("which data/node you want to access");
[example you want to access heading tag:ArticleList/Article/Heading]
//to display the nodes
foreach(XmlNode node in articleList)
{
Response.Write(node.InnerText.ToString());
}
**This way we can read the data from the xml file, we are using xmldocument, xmlpath in the above mentioned code...
Gautham
|
|
|
|