|
Hi to all
I want to convert string of numbers to integer without using any in built functions like convert or parse
for ex "666"=666
|
|
|
|
|
How else would you do that, then?
What's wrong with Convert.ToInt16("666") or int.Parse("666")?
Why 666?
|
|
|
|
|
Convert.ToInt16("666") Will not convert to an integer, but to a short.
You can also use Int32.Parse("666").
It this is hell (666), then imagine the rest
|
|
|
|
|
|
What, like this?
int i = 1234;
string j = i.ToString();
System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
byte[] b = ae.GetBytes(j);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int k = 0; k < b.Length; k++){
sb.Append(b[k]);
sb.Append(", ");
}
Console.WriteLine(sb.ToString());
|
|
|
|
|
Use BitConverter . It will convert any simple data type to byte and reverse. (Very useful for network transmissions )
|
|
|
|
|
What hook will allow me to global catch when a control looses focus?
|
|
|
|
|
|
Are there any built in .NET functions for dealing with relative file paths? Specifically: if I have two absolute file paths:
<br />
string fileNameA;<br />
string fileNameB;<br />
and I want to change fileNameB to be relative to fileNameA. Is there any way to do this with .NET, or should I just roll my own? Even just a way to tell fileOpenDialogs to return string names relative to the current working directory would be helpful.
Thanks
Dave
|
|
|
|
|
How can I get the unmanaged pointer of a managed method in C# so that I can store it in an integer within unmanaged memory? Also, how can I wrap an object around a pointer, with In/Out capabilities? It sounds kind of complicated, but I believe it is possible somehow. I'm trying to use a DLL in my program, which creates and uses a custom structure (in this case in the unmanaged memory). Luckily, there is a function in the DLL which allows me to retrieve the address of the structure, and I know all of the members in that structure through documentation. The part that trips me up is that the structure stores pointers to functions, and in order to use the DLL the way I would like, I want to change those pointers to my managed C# methods. As for the structure itself, I would like to wrap a managed structure around a pointer so that I can access the fields within it as well as write to those fields, kind of like a two-way link between the managed and unmanaged memory...
I only wish there were an easier way to explain all this. Does anybody know what I'm talking about?
|
|
|
|
|
|
I wonder if there is a difference between sending a broadcast or a multicast message on a single network (IE does not require routing).
|
|
|
|
|
I am calling an external app and redirecting the StandardOutput and StandardError streams so that I can capture them and display them in a TextBox. My app hangs in my timer Tick method (set to 20ms) when there is a lot of data on the StandardError stream, it hangs in the ReadLine() method with no warnings or output or anything. It just sits there and doesn't do anything, this also happens with the other Read methods EXCEPT for ReadToEnd() which will work. Unfortunately ReadToEnd() doesn't allow me to dynamically update the TextBox with the output as it comes in from the external process (using Process). When there's only a few lines of output it works fine, so my guess is there's some overflow or something with the data coming in too fast, but I can't figure it out.
I've tried many different things to get this to work with no luck, so am posting here hoping that this is a known issue or some way around this. TIA
|
|
|
|
|
I have reviewed several articles and examples to start processes on remote machines. The problem I have is that I cannot make any interactive. If the processes is created on the local machine if works fine. Remotely, however, the process shows in the process list but not applications nor is it interactive. I have changed the remote machine's WMI service to "Interact with Desktop" with no success. Has anyone been able to accomplish this without a separate service running on the remote machines?
Thanks in advance!
Paul
|
|
|
|
|
Windows 2000 SP3 removed the ability to remotely start processes in interactive mode for security purposes. Windows XP has always disallowed this. It is likely the samples you are referring to were written prior to SP3. I'm sure there is KB article on this, but I couldn't find it. I believe there are workarounds, but they're not recommended.
|
|
|
|
|
Is there a way to turn off the underline of text on a linklabel control?
|
|
|
|
|
Does
LinkLabel.Font.Underline = false not work?
|
|
|
|
|
It doesn't.
Even if the link label used that property to decide if it should underline the link (it uses the LinkBehavior enumeration), the Underline property of Font is read-only.
Charlie
if(!curlies){ return; }
|
|
|
|
|
linkLabel1.LinkBehavior = LinkBehavior.NeverUnderline;
Charlie
if(!curlies){ return; }
|
|
|
|
|
|
I'm registering a well known service that itself loads other components dynamically as requested by the client. I'd like to be able to determine when the client becomes disconnected from the remote service (say, if the connection is broken) so I can unload those components. I've read some things about connection lifetime services, but in my testing, they didn't
seem to work.
Has anyone done this and can point me in the right direction?
Thanks!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
You may not like this answer....I had a situation where I had users from all over the country connecting to a remote object. I had the need to do two things: show everyone who is using the server -and- b) know when one of the users lost their connection.
My approach was to deploy a global object. It is a Singleton. It holds an array of those connected to the server and has a 6 hour lifetimeservice. This helps to assure I do not lose my name list while users are on but inactive.
I have each client connect to the global object and execute PublishIdentity("name");
I then have two threads running:
thread a) on client sends pings (NotifyGlobal("name")) to the global object every 15 minutes telling it the client is alive.
thread b) on server checks lists for users who did not respond in more than 30 minutes. Those are purged from the list.
When there is nothing in the list and my time expires I am purged. I use that to indicate I have to shut down my thread in the destructor. You could use the zero count to indicate when to clear your objects.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
theRealCondor wrote:
You may not like this answer
Actually, it's a great answer! I hadn't even thought about doing my own lifetime service management. I guess sometimes I can't see the forest for the trees!
Thanks!
Marc
Latest AAL Article
My blog
Join my forum!
|
|
|
|
|
Great!
It works well for me. The 15 minute thread on the client dynamically updates a box on their workstation showing them who is on the server in real-time.
Once I got all of the remoting working, implementing this addition was so simple I could never let management know. (You'll get lots of kudos for implementing something so simple yet looks so complex)
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
I've been struggling with a remoting problem that is somewhat similar. In general terms:
- N number of clients talking to a server.
- Any client can alter privileged data but only one can do it at a time.
Sounds deceptively simple right? The trick is that being remoted over the web transport the server can't "ping" the client because of network topology routing isn't guarenteed (thinks like NAT are a good but often a necessary evil). Some of the operations can be a little long so just keying in on "time on CPU" isn't sufficient.
So Client 0 grabs the privileged resource to manipulate locking out other clients but something goes hiddeously wrong. Wrong to the point where no exception can be caught. This might happen if the machine is disconnected or the CLR is just plainly forced to unload. The server still thinks Client 0 is the only one altering the privileged resource and won't let any of the other clients access it.
I can't come up with a clean way to keep the system sane from unnatural disconnects. Because of other parts of the application and because ultimately the CLR unloading is beyond the scope of any runtime code the only way to "fix" hanging connections is to manulally kick dead connections.
I've tried but failed to find a way to handle this beyond handling it manually. What good are machines if I have to contantly fix things for them? If anyone has any good insight into how to handle this type of problem I'd love a good hint.
|
|
|
|