|
|
Interesting idea!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
hi friends,
as you know, when you initialize a String, you can achive the characters by:
String str = "hello";
char character = str[0];
but i want to achive to the character without using any methods or facilities prepared in String class. how can i write a method to achive?
thanks
modified on Sunday, June 29, 2008 1:36 PM
|
|
|
|
|
Sajjad Izadi wrote: int charPosition = str[0]; //or str[int index]
it returns a char. Your example will show the ascii value of the character at the supplied index and not the character.
Sajjad Izadi wrote: but i want to achive to the character without using any methods or facilities prepared in String class. how can i write a method to achive?
Looks like someone asked you this for an interview ? You can iterate though the string like this
foreach (char c in str)
{
Console.WriteLine(c);
}
|
|
|
|
|
oh excuse me you are right, it returns a char.
but i don't want to use 'foreach', too.
i want it for something like an interview .
thanks again
modified on Sunday, June 29, 2008 3:15 PM
|
|
|
|
|
I don't think that there is a way without using anything related to string class. I am not sure though.
|
|
|
|
|
How about this
string str = "hello";
char[] c = System.Text.ASCIIEncoding.Unicode.GetChars(
System.Text.ASCIIEncoding.Unicode.GetBytes ((str)));
|
|
|
|
|
|
If this is the interview question where you have to reverse a string, or ToUpper it or something like that without "using any built in methods" then you can assume you are able to use the char this[int] indexer. Good luck.
|
|
|
|
|
I am doing a program that inserts pictures to a panel. I have a progressbar that shows how long time it takes to upload. The problem is that i want to Join() this thread so it waits til its finished loading. I tried to use threads but it doesnt work because of threads between different controls... So i read and tried to understand how to work this out. Now ive done it with backgroundworker and it works but how should i do to Join()...
//Sebastian
|
|
|
|
|
Explain a bit more:
You've got a background thread that inserts pictures into a panel? Why do you need a background thread for this?
You want to Join() the background thread to...what?
|
|
|
|
|
Member 3918028 wrote: The problem is that i want to Join() this thread so it waits til its finished loading
You want to join with the main thread ? Then what is the point in running the process on other thread ? Do it in the main thread.
Background worker doesn't offer any thing to join. You can use AutoResetEvent to wait and signal when it is done.
Hope it helps
|
|
|
|
|
Hi All,
I have a C# application in development (using WPF UI) All is working as expected when Debugging in Debug/Release modes. Starting these different versions directly from the Bin\Debug or Bin\Release also works as expected.
As part of the preliminary testing before I give this to anyone else for more testing I built an installer version using Inno Setup (I'm using VCSharp Express). The installer is also doing its thing properly (as far as I can tell). All the applications bits and bobs are present and in the right places and the application starts and performs its checks and reports back as it was designed to do so.
The UI Comprises 2 main views, one of which contains a DataGrid and a TreeView for browsing the machines directories. If I start the application using the Desktop ShortCut icon created by the installer, this browser view doesn't work ... if I launch the same .exe (contained in Program Files directory) the browser view works ...
The VSExpress lack of JIT Debugging is really a PITA now, and I'm really not sure why launching the same .exe two different ways should make any difference.
If anyone has any ideas of things to check i'd really appreciate it.
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
It turns out that my install scrip wasn't configuring a Start In location when it created the Start Menu/Desktop short cuts ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi
i want to detect some shapes(include numerical or alphabetical characters) in any image by Image Processing Algorithm, but i need a full article about this, can anyBody help me ?
thanks
|
|
|
|
|
What you're mentioning is called OCR -Optical Character recognition-.
Try This article[^]
You may find several open source projects at code.google.com[^] Including Tessact & another one called OCRopus. Unfortunately both are in C++ code, not in C#.
For C# OCR capabilities you may search for commercial/Free libraries on Google[^]
Regards
|
|
|
|
|
thanks Nader
you mean that i search about OCR technology (like this[^]) ?
|
|
|
|
|
hi all,
I want to open microsoft outlook from c# windows application,(and i will pass the To email, subject, content as parameter)....
please help me how can i do that??/
thanks all
|
|
|
|
|
You could use mailto , it works with Process.Start which is nice, and you even use it exactly the same as in html.
Example:
string subject = "?subject=My Subject";
string body = "&body=The first paragraph.%0A%0AThe second paragraph.%0ANew line.";
Process.Start("mailto:cheese@sandwich.com"+subject+body);
You don't need to split up the string, it just makes it a little easier to manage.
Oh yeah, and just a simple title like "open outlook with c#" would have been nice, we alread know you want help and I've no idea what the hell those extra E's are for, infact all those axtra letters are going to get you less help.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Couple things. First, pick a better subject line. Secondly, get rid of the , and last of all, you may want to look into the Office Interop Library about working with Outlook in C#...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi to all the CodeProject gurus. I'm quite new to OOP and C#, and when I face a new design problem I wonder if there could already be a "standard", commonly used way to solve it, but I don't have enough experience with C# to find it
The problem: I'm writing a class which parses incoming data bytes from the serial port looking for messages of a particular communication protocol. So, my parser works inside the SerialPort DataReceived event, processes all the incoming data and, when a new message is found, should be able to communicate it to the client application.
My questions is: Is there a commonly used approach to pass data to the other classes, in this kind of situations?
I was geared towards using a Queue of messages, so that new messages are added to the queue from the parser - myQueue.Enqueue(message) - and "consumed" by the application, which sits in a loop like:
while(true)
{
if(myQueue.Count != 0)
{
message = myQueue.Dequeue();
}
Thread.Sleep(10);
}
Is there any better way? And is this thread-safe? I remember that DataReceived works in a different thread from the main application, so I'm not sure about the call to myQueue.Count .
Thanks in advance and kind regards,
Andrea
|
|
|
|
|
I think this approach is Ok, but polling the queue every 10 ms is not a good idea, instead you can create a event in parent class (which holds serial port), the client(the one which is having while loop) can register for it, as soon as the data comes in SerialPort DataReceived event trigger the custom event to client class!
|
|
|
|
|
Thank you for the suggestion, I ended up with an event driven approach as you suggested, and I'm passing data from the serial port event to the main thread using a mailbox based on an AutoResetEvent.
Regards,
Andrea
|
|
|
|
|
Winform program,
How to complex sort of the treenodes?
such as, friends list of IM, the friends online are top always.
even according to the status of different(online or offline) sort of Text.
How do such a tree control with C# in WinForm?
|
|
|
|
|
You have to do the sorting yourself by associating a comparer with the tree nodes. You could also do this by not sorting at all and adding tree nodes in the correct order.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|