|
All the data in a computer can be represented as numbers (bytes are numbers). So, you can use string.Format() to represent that data as a string.
[edit]
IF you're talking about a single binary digit as the input, then you simply transform your two bits into two bytes, using the bitwise operators to set your byte to 1 or 0 based on the state of the bit.
[/edit]
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
That isn't the prob.
I want to take 2 and only 2 chars of input and no moore.
And it should (if possible) not need the enter key to be
pressed at all.
Casting is easy and I don't do it with string.Format()
anyway.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Ah! You're asking about input, not output. Ok.
Y'know, I haven't written a console application with the need to do that, so I can't help much with that. However, if you turned it into a window display, it would be very simple.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Yes. I also know that but now it's in
a console and it stays there for a while.
Could anyone else please help me with this.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
I did a search for you, since I was curious too. Here[^]'s a link that looks to be right on the money. (It's written in VB.NET, but you can use it or translate only the piece you need.)
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi, i have wrote this code to create a static class
public static class Tools
{
public static Tools()
{}
}
but the complier give me this error :
The modifier 'static' is not valid for this item. (referring to the class declaration)
What i miss?
thanks
|
|
|
|
|
static class es is a new feature in .NET 2.0 (still in beta). Are you sure you're not programming for .NET 1.1?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello
You've missed reading MSDN:
"The static modifier can be used with fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types."
With best regards,
Andrew
|
|
|
|
|
A static class can't create an object
and thereby it can't have a construcor.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Thats wrong. In .Net static constructors are allowed which are called the first time the class is used:
public class Blubb() {
static Blubb() {
}
}
Note that no more modifiers are allowed and that this constructor cannot be called explicitely (the framwork handles this).
|
|
|
|
|
OK thanks.
I didn't know that.
I'll maby use it someday.
The PROgrammer Niklas Ulvinge aka IDK
|
|
|
|
|
Consider:
public abstract sealed class Tools
{
private Tools(){}
}
The static modifier in c#2.0 is implemented this way.
|
|
|
|
|
thank you very much.
Actually i'm using .net 1.1, i didn't know that this feature is implemented only in 2.0.
I'll try another way...
|
|
|
|
|
Hi Guys,
Is it possible to Filter multiple file types with the FileSystemWatcher component.
I tried watcher.Filter = "*.doc;*.ppt"; but this doesn't work.
Any ideas?
Thanks
|
|
|
|
|
The documentation here[^], doesn't mention anything about allowing multiple filters.
You could simply use two FileSystemWatcher instances. Or, you could use one FileSystemWatcher, and process the filename yourself to only deal with the extensions you care about. Either way, you reach the same goal.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
I'm sending data between a async socket client and server. 99% of the time all goes well, but sometimes the data received at the client is somehow received in two parts. A numeric example:
Server sends data: 20000 bytes
Client receives data: 15000 bytes
Client receives data: 5000 bytes
As you can see, the client somehow splits the data in two parts.
What might trigger the socket.EndReceive() method so early?
How can this happen and more important: how can I prevent this data mutilation?
|
|
|
|
|
This happens for valid reasons within normal operation, so you should just concentrate on how to deal with the result (not really a mutilation, just a separation as it travels over the network).
Your protocol must somehow indicate the beginning and end of a message. One simple way is to always end a message with a unique byte signature of some kind. Another way is to begin every message with a set number of bytes (say 4) that indicates the byte length of the rest of the message.
After you have established a way to know the beginning and end of the message, you edit your receive code to notice the difference, and to process a whole message at a time. (Merge split message chunks into one byte array if needed.)
Another thing you should watch out for, is a common scenario like this:
Server sends data: 1500 bytes
Server sends data: 2100 bytes
Server sends data: 1400 bytes
Client receives data: 5000 bytes
In that case, you will also need to know the beginning and end of a message, so you can process the messages individually from the received data.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
John, thank you for your response.
I always thought that sending data with a smaller size than the used socket buffer
would prevent data from splitting up (it easily fits in there, so why would it split, right?).
I obviously was wrong.
Testing this client was performed locally on my desktop computer (P2.4GHz) turned out fine and no data was cut in multiple pieces. But the client will in the end be a background process on a heldheld computer with WinCE and limited processor power (200MHz). Testing the client on this handheld showed large numbers of data failure.
Back to the drawing boards to redesign my protocol.
Thanks you very much!
Greetings,
Dirk
Holland
I can't get no satisfaction.
|
|
|
|
|
Darth.Vader wrote:
Thanks you very much!
You're welcome! I hope the change goes quickly for you.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
John,
One thing remains unclear to me:
When or if a data packet sent gets split up, can I assume that it is received in good order? Roughly this idea: server sends 'abcde' client receives (in case of split data) 'a' , 'b', 'c', 'd', 'e' and not 'a' , 'e', 'b', 'd', 'c'?
I need to be sure about this behaviour so I can adapt my code to handle this.
Thanks again!
I can't get no satisfaction.
|
|
|
|
|
How can i do to write function to convert MS Access database to MYSQL database.
I tried so hard and got so far
|
|
|
|
|
Hi!
I use a PropertyGrid to display the properties of certain objects. Now what is that stange button next to the alphabetical sort button? It is always disabled. Is there a possibility to remove this button? It has already confused users because its always disabled and doesn't do anything.
|
|
|
|
|
Hello,
I print same word document consecutively by using C#. But Word document's content changes in each printing operation. For instance; my word document is "master.doc. In each consecutive print, i see "master.doc" in print queue. I wanna change word document display name in print queue. For example if i write A City data to word document, i wanna see word document display name in print queue is "A_master.doc" printing, then if i write B City data to word document, i wanna see word document display name in print queue is "B_master.doc" printing. I use Word object to print. How can i do this? How can i set word document display name in printer queue? Is there easy way to do this?
I read this article : http://www.codeproject.com/dotnet/NET_Printer_Library.asp
But,is there a command to set,change word document display name in printer queue?
Thanks.
|
|
|
|
|
|
Hi all,
I have a problem with a hit test using Region. I'm using this code but it doesn't seem to work. Shape is a Panel and Map is a PictureBox
public bool Hit(Shape shape)
{
Map map = (Map) this.Parent;
Region thisRegion = (Region) this.Region.Clone();
thisRegion.Intersect(shape.Region);
Region r = new Region();
r.MakeEmpty();
Graphics mapGraphics = map.CreateGraphics();
return (!thisRegion.Equals(r, mapGraphics));
}
Anyone has an idea or suggestion to make this work?
Thanks,
Marco Glorie
|
|
|
|