|
And how exacly could I do that in C# (could you show it to me in C# please) ?
|
|
|
|
|
OK, just for fun, I re-wrote your delphi code in C#. Not that I'm sure this implementation is even correct, or that it does anything desirable, but it will compile. So, in TMyBookClass.cs, we have:
using System;
using System.Collections;
namespace Books
{
public abstract class TMyBook {
string FName;
public abstract TMyBook Create(string AName);
public virtual string Name {
get { return FName; }
set { FName = value; }
}
}
public class TMyBookClass : TMyBook {
TMyBook ActiveBook;
ArrayList Books = new ArrayList();
public struct TBookInfo {
public string Name;
public TMyBook BookInstance;
public TMyBookClass BookClass;
}
public TMyBookClass(string AName){
this.Create(AName);
}
public override TMyBook Create(string AName) {
this.Name = AName;
return this;
}
public int FindBook(string AName) {
for(int result = 0; result < Books.Count; result++) {
TBookInfo bi = (TBookInfo)Books[result];
if (bi.Name == AName) { return (result); }
}
return -1;
}
public void RegisterBookInfo(string AName, TMyBookClass ABookClass) {
TBookInfo bi = new TBookInfo();
bi.Name = AName;
bi.BookClass = ABookClass;
bi.BookInstance = null;
Books.Add(bi);
}
public TMyBook GetBook(string AName) {
int index;
index = FindBook(AName);
TBookInfo bi = (TBookInfo)Books[index];
return bi.BookClass.Create(Name);
}
public void SetActiveBook(string ABookName) {
ActiveBook = GetBook(ABookName);
}
}
}
Then, in the main class of a console application, you could...
TMyBookClass TMyNewBook = new TMyBookClass("New Book");
TMyNewBook.RegisterBookInfo("New Book", TMyNewBook);
TMyNewBook.SetActiveBook("New Book");
|
|
|
|
|
I have string array, I converted that one to char array
I am trying to access values of character array and trying to convert them to integer.
code follows here
string rs="999";
char[] rs1=rs.ToCharArray();
int i;
int sum=0;
for(i=0;i
|
|
|
|
|
GetOn&GetGoing wrote:
I am getting the address value...
Try the following:
int sum = 0;
int i = 0;
string rs = "999";
char[] rs1 = rs.ToCharArray();
foreach(char c in rs1)
{
i = Convert.ToInt32(c);
sum += 10 * i;
Console.WriteLine(sum.ToString());
}
- Nick Parker My Blog
|
|
|
|
|
|
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; }
|
|
|
|
|