|
Of course it works, how dare you doubt that?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's a great article by the way
Regards,
Jason Pezzimenti.
|
|
|
|
|
Thanks. I wanted the problem solved at that time, and no solution seemed to be available, so...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
mark_me wrote: its icon remains and disappears only when i move mouse over it.
I wonder if it is an XP thing, I have something at work (put in place by those IT Gods who maintain our infrastructure) that creates the task manager icon at start up, it disappears if I do this.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Such exit code doesn't get executed when you kill a process. That is not the solution. Read the article that was mentioned, it works!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thanks and great article !!!
Thanx alot
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
How to implement paint brush in c# using mouseevent?
Neelam Verma
|
|
|
|
|
http://www.codeproject.com/KB/miscctrl/Painbrush_Color_Picker.aspx
|
|
|
|
|
The answer to this depends entirely on what you mean by paint brush and by using mouseevent.
Can you explain a little more clearly?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
theré's all kinds of brushes. This little article[^] shows what a gradient brush can do for you; but maybe all you want is a SolidBrush?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
I created a proxy that listens on a port for a requests, and then redirects them to a server. For that I created a listening socket, and a client socket that streams the data.
The problem is that the server is using Authentication (for instance NTLM, or digest) and I need to authenticate the request.
I know that I can do it in a webrequest, using CredentialCache object; something like this:
CredentialCache credCache = new CredentialCache();
if ((auth & (uint)EAuthenticationFlags.eWindows) != 0) {
credCache.Add(URL, "Negotiate", (NetworkCredential) CredentialCache.DefaultCredentials);}
webRequest.Credentials = credCache;
However, I am unsure how to do it if all I have in my hand is a socket and a stream of data. Something like this:
ClientSocket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnClientReceive), ClientSocket);
DestinationSocket.BeginReceive(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, new AsyncCallback(this.OnRemoteReceive), DestinationSocket);
And the code for the callbacks [b]OnClientReceive[/b] and [b]OnRemoteReceive[/b]:
protected void OnClientReceive(IAsyncResult ar)
{
try
{
int Ret = ClientSocket.EndReceive(ar);
if (Ret <= 0)
{
Dispose();
return;
}
DestinationSocket.BeginSend(Buffer, 0, Ret, SocketFlags.None, new AsyncCallback(this.OnRemoteSent), DestinationSocket);
}
catch
{
Dispose();
}
}
protected void OnRemoteReceive(IAsyncResult ar)
{
try
{
int Ret = DestinationSocket.EndReceive(ar);
if (Ret <= 0)
{
Dispose();
return;
}
ClientSocket.BeginSend(RemoteBuffer, 0, Ret, SocketFlags.None, new AsyncCallback(this.OnClientSent), ClientSocket);
}
catch
{
Dispose();
}
}
Does anybody has any suggestions of where the authentication should take place and how? Can I append a credentials object somehow to the socket o or to the stream of data? or worst case scenario, can I just append the correct http headers?
Thanks in advance for your time,
cheers,
Jo
|
|
|
|
|
List < string > lst = new List < string > ();
lst.Add("FirstValue");
lst.Add("SecondValue");
lst.Add("ThirdValue");
lst.Add("FourthValue");
Dictionary < string , int > dic = new Dictionary < string , int > ();
dic = lst.ToDictionary < string , int > ( ???? )
|
|
|
|
|
If you say why you want to do this and what the int value represents, it would be easier to advise you,
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
int is value of repeated string.
suppose lst.Add("this");
lst.Add("this");
Console.Write(dic["this"]) // will be 2 because of repeatation of "this".
|
|
|
|
|
this is known that same Key will throw exception but when key is repeated int is incremented and key will not register ( as it will throw exception)
|
|
|
|
|
try this:
public partial class ListToDictionaryTestForm : Form
{
List<string> testList = new List<string>();
public ListToDictionaryTestForm()
{
InitializeComponent();
testList.Add("one");
testList.Add("One");
testList.Add("two");
testList.Add("three");
testList.Add("one");
testList.Add("three");
testList.Add("one");
OutputResults(testList);
}
private void OutputResults(List<string> testList)
{
var itemcounts = from s in testList
group s by s into g
select new
{
key = g.Key,
val = g.Count()
};
Dictionary<string, int> results = itemcounts.ToDictionary(k => k.key, v => v.val);
foreach (KeyValuePair<string, int> kvp in results)
{
lboxResults.Items.Add(string.Format("{0} : {1}", kvp.Key, kvp.Value));
}
}
}
This is just a Form with a ListBox on it.
I've just realized that this can be abbreviated slightly:
private void OutputResults(List<string> testList)
{
Dictionary<string, int> results = (from s in testList
group s by s into g
select new
{
key = g.Key,
val = g.Count()
}).ToDictionary(k => k.key, v => v.val);
foreach (KeyValuePair<string, int> kvp in results)
{
lboxResults.Items.Add(string.Format("{0} : {1}", kvp.Key, kvp.Value));
}
}
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Friday, July 31, 2009 11:38 AM
|
|
|
|
|
However that doesn't satisfy the requirement "without using loop?"
you'll need stronger lambda magic, or an entirely different kind of Force!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hey! Play fair. It only uses the loop, at least explicitly, to demonstrate that it has worked.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
as Dan points out below, there is a hidden loop in your magic, and as you said there is a visible one you don't need, so your solution actually contains two loops, that's way too much.
FWIW: The only way I see without loops is with recursion
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: as Dan points out below, there is a hidden loop in your magic
That's why I explicitly said explicitly.
Luc Pattyn wrote: FWIW: The only way I see without loops is with recursion
Hadn't thought about that. You're probably correct, although isn't that a form of looping? In fact, isn't it a double loop? Once on the way through getting the results, and again whilst unwinding the recursion stack?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Haven't seen a book yet that lists recursion as a loop construct; normally they only mention things such as for, while and do.
One must be careful, if the code is written in such a way that tail recursion is possible, then sooner or later (probably later) MS may come with a C# compiler that turns the recursive code into a loop, which to the OP (or his teacher?) would be unacceptable.
Going one step further, our computers execute loops all the time: fetch instruction, decode instruction, execute instruction; whether coded in micro-code or implemented in parallel hardware, each little piece is doing its job over and over. So maybe it can't be done? Or maybe yours is the solution they wanted...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: you'll need stronger lambda magic,
You're still using a loop then, you're just applying a layer of obfuscation to hide it.
The European Way of War: Blow your own continent up.
The American Way of War: Go over and help them.
|
|
|
|
|
this is a bad question ya know?
what is supposed to go in the dictionary?
I can only make some guess....
first you can't avoid a loop, so here woud be one
Rand r = new Random();<br />
foreach(var s in lst) dic[rand.Netx()] = s;
but maybe we could use some LINQ magic to hide the loop?
Random r = new Random();<br />
Dictionary<int , string> dic = new Dictionary<int , string>();<br />
dic = lst.ToDictionary <string, int>(s => r.Next());
How about that?!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
StreamReader bfr = File.OpenText(@"D:\Documents and Settings\home\Desktop\normal.txt");
Dictionary < string , int > dic = new Dictionary < string , int > ();
string[] str = bfr.ReadToEnd().Replace("\r","").Replace("\n"," ").Replace(" "," ").Split(' ');
int var = 1;
foreach (string i in str)
{
if(dic.TryGetValue(i,out var))
dic[i]++;
else
dic.Add(i,1);
}
foreach(KeyValuePair < string , int > i in dic)
if(i.Value > 1)
Console.WriteLine(i.Key + " " + i.Value);
Console.ReadLine();
THIS WAS THE TASK BUT I HAVE DONE IT USING LOOP.
I WANT IT TO BE DONE without USING LOOP
|
|
|
|
|