|
hello
i am reading a Wrox.Beginning.Microsoft.Visual.C.Sharp.2008 and i have question from exercises and it says
Create a delegate and use it to impersonate the Console.ReadLine() function when asking for
user input.
i am not sure i get the idea so please let me know
thank you
Gilberto
|
|
|
|
|
All it means is to create a delegate which allows you to call a method (in this case Console.ReadLine) without using that name.
delegate string MyMethodDelegate();
static void MyMethod()
{
MyMethodDelegate readALineFromUser = new MyMethodDelegate(Console.ReadLine);
Console.WriteLine("Enter your name:");
string inp = readALineFromUser();
Console.WriteLine("Your name is\"{0}\". ", inp);
}
Why would we use it?
Because we could change the input source from Console.ReadLine to MyBatchFileReadLine at run time without changing any of the code that uses readALineFromUser:
delegate string MyMethodDelegate();
static void MyMethod()
{
MyMethodDelegate readALineFromUser = new MyMethodDelegate(MyBatchFileReadLine);
Console.WriteLine("Enter your name:");
string inp = readALineFromUser();
Console.WriteLine("Your name is\"{0}\". ", inp);
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
thank you soo much OriginalGriff i now get the idea
but MyBatchFileReadLine i don't think that i came to that level for now ,so if you don't mind tell me what its story ?? ^_^
thank you again
|
|
|
|
|
"MyBatchFileReadLine" doesn't exist: I used it as an example of a potentially different input source - a batch file of names instead of the user typing each one directly.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
One of the best and most concise explanations of delegates that I've seen.
I must get a clever new signature for 2011.
|
|
|
|
|
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
10000 X thankes
|
|
|
|
|
You are welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Good afternoon,
I am using pdf clown library to extract the pdf contents.Now i want to extract the whole table content from pdf.
|
|
|
|
|
When you use a 3rd-party library, your best source of information is always the forum of the product.In this case it's here[^].
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
I got this Link[^] having same question with solution.
you can try using pdfsharp managed assembly. go there[^] to take a look.
I hope it might help you
|
|
|
|
|
Hello Experts,
I have a code of Keyboard Hook In which have a problem when i m tring to Capture Unicode Character then it's not working fine.
I know that i want to use MapVirtualKeyEx, ToUnicodeEx function to convert for Unicode.
But i am not unable to understand this function .
So Please can any one help me to convert it function for Unicode Support.
Private Function KeyboardProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByRef lParam As KeyboardData) As IntPtr
If (nCode >= NativeMethods.HC_ACTION) Then
Dim e As Pcdll.KeyBoardEventArgs
Dim keyCode As Keys = CType(lParam.vkCode, Keys)
Select Case True
Case CInt(wParam) = NativeMethods.WM_KEYDOWN Or CInt(wParam) = NativeMethods.WM_SYSKEYDOWN
If keyCode = Keys.LMenu Or keyCode = Keys.RMenu Then
Me._keyData = Me._keyData Or Keys.Alt
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.Menu, keyCode)
ElseIf keyCode = Keys.LControlKey Or keyCode = Keys.RControlKey Then
Me._keyData = Me._keyData Or Keys.Control
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.ControlKey, keyCode)
ElseIf keyCode = Keys.LShiftKey Or keyCode = Keys.RShiftKey Then
Me._keyData = Me._keyData Or Keys.Shift
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.ShiftKey, keyCode)
Else
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or keyCode, keyCode)
End If
Me.OnKeyDown(e)
If e.Handled Then
Return CType(1, IntPtr)
End If
Case CInt(wParam) = NativeMethods.WM_KEYUP Or CInt(wParam) = NativeMethods.WM_SYSKEYUP
If keyCode = Keys.LMenu Or keyCode = Keys.RMenu Then
Me._keyData = Me._keyData And Not (Keys.Alt)
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.Menu, keyCode)
ElseIf keyCode = Keys.LControlKey Or keyCode = Keys.RControlKey Then
Me._keyData = Me._keyData And Not (Keys.Control)
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.ControlKey, keyCode)
ElseIf keyCode = Keys.LShiftKey Or keyCode = Keys.RShiftKey Then
Me._keyData = Me._keyData And Not (Keys.Shift)
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or Keys.ShiftKey, keyCode)
Else
e = New Pcdll.KeyBoardEventArgs(Me._keyData Or keyCode, keyCode)
End If
Me.OnKeyUp(e)
If e.Handled Then
Return CType(1, IntPtr)
End If
End Select
End If
Return NativeMethods.CallNextHookEx(Me._hKeyboardHook, nCode, wParam, lParam)
End Function
Reqired Link is here :
Global Windows Hooks[^]
Thanks
If you can think then I Can.
|
|
|
|
|
This code does not look much like C# to me. Try posting in the correct forum.
I must get a clever new signature for 2011.
|
|
|
|
|
O Sorry Sir,
But if u have the solution for that pls help. Because C# and Vb.net is Mostly similer only syntex changes.
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: Because C# and Vb.net is Mostly similer only syntex changes.
That may be true but we have separate forums for a reason. Lots of people know VB.NET or C# but not both.
I must get a clever new signature for 2011.
|
|
|
|
|
He has. He also tried posting it to Q&A as a link here - deleted.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Agree
If you can think then I Can.
|
|
|
|
|
Hi,
I just got a new task to do. I need a desktop solution which will contact to another desktop application. My desktop application will send some message to the remote desktop application and the remote desktop application will print that message by the connected printer of that remote PC. Both of the application will be written by me in C# 4.0.
Now, how can I achieve this goal ? So far I thought, I will run IIS to the remote Desktop where the IIS will be running an ASP.NET Web Application. My application will post the message to an URL of the remote IIS served website, and that URL is an ASPX page, which will invoke a C# application and that application will print that message.
But, obviously it costs more by too much overhead. Cannot I directly connect to that printing application (using IP address or some other token) and send the print command ? Is WCF is the technology that can solve this problem ? If so, can you please show me any useful article ?
I have used WCF in my ASP.NET web application so that a remote desktop application can connect to my Web site and download information, but I did not host WCF in a Windows Application and I am not sure if that approach is the really best fit for my problem. I am not sure if WCF can be used over internet when hosting the WCF in a Windows application.
Regards
modified on Friday, February 4, 2011 11:54 PM
|
|
|
|
|
You can use Client Server (Network ) Programming.
You can use also with the use of database to communicate with each other.
This Process is called Intranet in case of Using Web Part to use (With in a network).
First U must to create a server where your database or Browsers files will be store after that connect from the client machine and Use the same like internet.
Best Regard
If you can think then I Can.
|
|
|
|
|
Thanks for the keyword 'Client Server (Network) Programming'. I searched in Google with 'Client Server Programming in C#' and found the VERY RIGHT article that just solved my problem.
Here is that article : Introduction to TCP client server in C#[^]
|
|
|
|
|
|
Find yourself some dictionaries with "known" words from various languages, and check if there's one with a lot of hits
I are Troll
|
|
|
|
|
I'm trying to determine is the value has already been encrypted so I don't encrypt it again.
Everything makes sense in someone's mind
|
|
|
|
|
Intuitively, I believe that this is impossible.
How would the function tell the difference between an encrypted string, and a string of random characters?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
It wouldn't. OTOH, how many people will decide to encrypt random data?
It'd be a lousy way to gain access to something that you don't know; it might even be an MP3-file in Base64 that's encrypted in there. Counting the number of hits against a dictionary is enough indication if you merely want to determine whether you're dealing with something in plain-text or not.
I are Troll
|
|
|
|