|
I'm trying to encrypt a string... you have any suggesstions on how to efficiant the code?
|
|
|
|
|
Use streams. Use a StreamReader to read the input stream and a StreamWriter to write it. That also takes care of the multi-byte character code problem.
---
b { font-weight: normal; }
|
|
|
|
|
1. How do I determine on which row/line/ is the cursor?
2. How can I set a background color of a line?
|
|
|
|
|
Cristoff wrote: 1. How do I determine on which row/line/ is the cursor?
GetCharIndexFromPosition will accept some coordinates and return the index of the character under that point. GetLineFromCharIndex will get the line from the character index.
(Try consulting the help documentation or even just looking through the intellisense, the method names are quite simple )
Cristoff wrote: 2. How can I set a background color of a line?
Unless you override the painting of the control there is no built-in way to do this. Take a look at some of the articles regarding the RichTextBox here on CP for ideas on how to do this. (There is one I remember that draws the line numbers, should be quite simple to re-write this to background fill the lines).
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Thank you! I'm just starting this stuff again and I'm lost!
I think I found the article! I don't know why I wasn't able to find it before????
Great line about Land Rover!
-- modified at 15:22 Sunday 14th May, 2006
|
|
|
|
|
Try: Numbered TextBox
CP search didn't work so this was found through Google, limiting the search to www.codeproject.com.
[edit]While I was looking for the article it looks like you found it, hopefully it's the same one[/edit]
Cristoff wrote: Great line about Land Rover!
Thanks , I can prove this from experience
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Ed.Poore wrote: Try: Numbered TextBox
CP search didn't work so this was found through Google, limiting the search to www.codeproject.com.
[edit]While I was looking for the article it looks like you found it, hopefully it's the same one[/edit]
Thank you! I haven't used codeproject site for quite some time and I haven't searched correctly.
Cristoff wrote:
Great line about Land Rover!
Thanks , I can prove this from experience
I know too I always have to suppress my hooliganish instincts and try to behave civilized.
|
|
|
|
|
An array a1[1 10 8.1 6 ]
I want another array a2 constains the index of a1 from small to large
a2 should contain.
[0 3 2 1]
Is there any build-in method in C# to do that?
THX
|
|
|
|
|
No, there is no built-in method which produces the results you need. You'll need to write that one from scratch.
Josh
|
|
|
|
|
static int[] IndexArray(Array a1)
{
SortedList list = new SortedList();
int[] indices = new int[a1.Length];
for (int i = 0; i < a1.Length; i++)
list.Add(a1.GetValue(i), i);
list.Values.CopyTo(indices, 0);
return indices;
}
Note this method doesn't work if there's more than one of the same value.
|
|
|
|
|
can anybody tell me simple sorting method of arraylist which contains objects of keys and values?
san
|
|
|
|
|
Please explain a bit more. Do you mean you have an ArrayList with objects which have a Key and a Value property? Or something different?
(probably some code how and with what you fill the list would be helpful)
|
|
|
|
|
Hi,
I have tracked a strange behavior when I close a .NET TCP Socket.
I wrote a TCP-Server which listens on port 6000. I now connect with an self written TCP-Client and everything works fine. When I want to disconnect the client from the server I call code like this:
<br />
public void Disconnect()<br />
{<br />
if (socket.Connected)<br />
socket.Shutdown(SocketShutdown.Both);:~ <br />
socket.Close();<br />
socket = null;<br />
}<br />
When I now run "netstat -a -p tcp" from the commadline I can still see the connection with the state:
localhost:6000 -> localhost:6001 = CLOSING_WAIT (translated from german: SCHLIESSEN_WARTEN)
localhost:6001 -> localhost:6000 = FIN_WAIT_2 (translated from german: FIN_WARTEN_2)
Looks like there are some fragments of the connection still there. By the way... I am not able to create new connection on the same port at this time. Only when I finish my application, the connection between 6000:6001 in "netstat" is gone.
The strange thing is, that if I disconnect with the code below, everything works fine. I cant find any connections with "netstat" after the disconnection, and I'm able to create a new connection with the same ports...
Here is the code:
<br />
public void Disconnect()<br />
{<br />
socket.Close();<br />
socket = null;<br />
}<br />
So... can someone tell me what is happening here? As far as I know it should be right and neccessary to call socket.Shutdown(...) with the TCP-Protocol. I read a lot of MSDN documentation but couldnt find any clues to this. As far as I tracked the problem, it only appears when I call socket.Shutdown(Socketshutdown.Send) . socket.Shutdown(Socketshutdown.Receive) works apperntly fine.
Maybe there is some socket coder outside that can help me.;)
Thanks in advance,
Snow.
|
|
|
|
|
Tooltips for disabled buttons
Sayan
-- modified at 10:28 Sunday 14th May, 2006
|
|
|
|
|
You should at least try to formulate a proper question...
|
|
|
|
|
no
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Sayan007 wrote: Tooltips for disabled buttons
Sometimes people make statements rather than ask a question. But, there isn't even a verb in that!
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I'm trying to build a little C# program using regular expressions that will filter out the email address and the reason for the mail not reachin the destination.
All that I really want is to extract the email address and the specific reason why the message wasn't sent or recieved.
Example:
Hi. This is the qmail-send program at domain.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.
email address@domain.com:
Sorry, no mailbox here by that name. (#5.1.1)
Thanks in advance for the help.
Regards
Jorge
-- modified at 6:34 Sunday 14th May, 2006
|
|
|
|
|
email\s([^@]+@[^@]+) r|\n|\r\n)+(.*)
This is very basic, but should get the work done.
match[1] is the mail address, match[3] is the reason of the failure.
regards
-- modified 12-Sep-18 21:01pm.
|
|
|
|
|
hello
maybe you can help me to make a comobox to get the values from DB .
and how can I know and save what was picked there.?
thank you
|
|
|
|
|
combobox1.DataSource = ds.Tables[0];
combobox1.TextMember = "<field>"; // I think it's textdatamember, or text, this is the name of the field you want that the user will see
combobox1.ValueDataMember = "<field>"; // this is what you want to know, eg. ID
to get it you do combobox1.Items.SelectedItems - will get the collection of the selected items, and by the indexer you can watch what you want.
|
|
|
|
|
|
Hi i am using VS 2003 , and i want to break at a particular place when a value of object x is changed. IN VB6 we have something called Watchwindows, where we can set a condition when value changes to break
san
|
|
|
|
|
In Visual Studio there is a breakpoints window where you can set conditions for breakpoints.
---
b { font-weight: normal; }
|
|
|
|
|
I'm trying to establish a good way of doing something before finalising my codegen.
Below is an example:
private void Form1_Load(object sender, EventArgs e)
{
Employee emp = ReallyCoolFuncSingle();
}
public Employee ReallyCoolFuncSingle()
{
Employee e = new Employee();
Person p = CoolFuncSingle();
e = (Employee)p;
e.Age = "100";
return e;
}
public Person CoolFuncSingle()
{
Person p = new Person();
p.PersonName="billy bob";
return p;
}
public Person[] CoolFuncArray()
{
Person[] p = new Person[2];
p[0] = new Person();
p[1] = new Person();
p[0].PersonName = "billy bob";
p[1].PersonName = "frank";
return p;
}
public class Person
{
private string _PersonName;
public string PersonName
{
get { return _PersonName; }
set { _PersonName = value; }
}
public static explicit operator Person(Employee e)
{
Person p = new Person();
p.PersonName = e.PersonName;
return p;
}
}
public class Employee
{
#region person stuff
private string _PersonName;
public string PersonName
{
get { return _PersonName; }
set { _PersonName = value; }
}
#endregion
private string _Age;
public string Age
{
get { return _Age; }
set { _Age = value; }
}
public static explicit operator Employee(Person p)
{
Employee e = new Employee();
e.PersonName = p.PersonName;
return e;
}
}
In essence, I'm trying to modify the Person object returned from some functions and return a super class of some sort - whether actually derived or not is not the issue.
It's a wrap and modify type of pattern.
The code above shows a few attempts.
Basically it all works fine for single objects (managed to get around the explicit operator restrictions), but won't work for arrays.
Any ideas?
Cheers,
Simon
> blog:: brokenkeyboards
> what I think of the OPTIONAL keyword in VB.NET? :: here
> CV :: PDF
> skype :: SimonMStewart
|
|
|
|