|
I was wondering if there is a C# equivalent to the 'with' stmt in vb.net ..
I have some code that sure needs it!
thks in advance .
|
|
|
|
|
Dato wrote:
I was wondering if there is a C# equivalent to the 'with' stmt in vb.net ..
No, there isn't, and some people think that there should not be, I'll explain why below.
Dato wrote:
I have some code that sure needs it!
So, put this code in a method in this object.
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|
|
I came up against this problem, too, and no, you can't always put the code in a method of the object. I don't see any reason not to have a with block statement, except that C++ didn't have one, which is a very poor excuse!
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
so what is the problem?
if you are going to set props on a something down a hirarchy like:
MyBlah.SomeBluh.LastWow.Gnu.BackColor=color.red;<br />
MyBlah.SomeBluh.LastWow.Gnu.ForeColor=color.green;<br />
MyBlah.SomeBluh.LastWow.Gnu.Text="hello you!"
it would be very simple to just make a temp holder for gnu:
GnuType g=MyBlah.SomeBluh.LastWow.Gnu;<br />
g.BackColor=color.red;<br />
g.ForeColor=color.green;<br />
g.Text="hello you!"
that would do the exact same thing . ok . you would have to type "g" infront of every prop , but thats about it...
//Roger
|
|
|
|
|
I think that using a temporary holder (many times) floods the memory untill the garbage collector comes. And how would you release the resources used by g ?
|
|
|
|
|
take a good long reading about reference types...
that will sort things out for you..
//Roger
|
|
|
|
|
I'm developing a software which is similar to PCAnywhere and would like to know how to send / simulate a mouse click (with co-ordinates and stuff) that is not form dependant meaning that i can send / simulate the mouse click anywhere i want, be it the taskbar, tray icon, etc. How do i go about doing it? Are there any samples for this sort of thing?
|
|
|
|
|
In Win98 or higher, there is a function called SendInput which you can use to send input as if it is coming from the keyboard, the mouse, or even another device. For any OS below that, you have to simulate it by using windows messages.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
After some searching yes that's the only way i guess but it seems to require me to define the structs, do you happen to know the full definitions and probably show me a sample syntax on how to call it?
|
|
|
|
|
|
Nuf said.
|
|
|
|
|
Nope, not sharp enuf
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi,
How can I find the names and/or IPs of the computers on my LAN (the ones that I see in Explorer)? Please help, I really don't have a clue...
Thanks a lot!
Andrei Matei
andreimatei@home.ro
|
|
|
|
|
|
Thanks a lot, just what I needed.
Andrei Matei
andreimatei@home.ro
|
|
|
|
|
Hi,
We can use an arraylist of objects as a datasource for a datagrid. We need to have public properties in that object to shown as columns. My question is if we are exposing another type as a public properties how can we show that.
It can be a master detail relation ship.
Cheers,
Venkatraman Kalyanam
Chennai - India
"Being Excellent is not a skill, it is an attitude"
|
|
|
|
|
What's the equivalent of the Win32 API keybd_event (or SendInput ) for .NET?
Thanks,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I don't know, but there is no rule that you can't use API's in .NET!
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I know, but why reinvent the wheel? You'd think that something like this would already be there, somewhere...
Thanks,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I had a similar question that I posted a couple of days ago, with mixed results. See thread:
http://www.codeproject.com/script/comments/forums.asp?msg=466571&forumid=1649#xx466571xx
I tried calling keybd_event from C# through an extern declaration, like this:
<br />
[DllImport("User32.dll")] <br />
private unsafe static extern void keybd_event(byte bVk, <br />
byte bScan, <br />
uint dwflags, <br />
ulong* dwExtraInfo);<br />
For me, this works the first time but is flaky after that. I'm not sure why, but it's possible that the last two parameter types are off -- I wasn't exactly sure what to use there.
|
|
|
|
|
|
My digging payed off!!
I found a class called SendKeys class in the System.Windows.Forms namespace. Not the most intuitive name, but hey, it's a lot better than that awful keybd_event.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
cool enjoy
|
|
|
|
|
I had a quick look at the SendKeys class but can you use that to send it remotely, I think that was what you wanted to do. I am also looking for remote components to can control terminals across a tellephone line, I found some cool stuff, but not key strokes or mouse events... Let me know if you need any other stuff...
Leon v Wyk
|
|
|
|
|
Can i use TCL with c#? is there any integration between them like there is in C++?
The whole reason for this is i need to add some form of version managment to my final year software engineering project (and its getting rather late in the day) My plans were to use the Sharp develop CVS library but as there is no documentation for this i cant work out what is happening or what im supposed to do!
So i thought the next best thing might be to use TCL expect so i can easily send and recieve lines to and from the console but its been a while since ive used TCL and its a bit messy so i'd much rather do it all in c#!
Does anyone have any ideas on how i can impliment basic version management in any readily available system (CVS, RCS, etc.) im getting so fedup of trying to get this to work im even debating writing my own version management system but i know there must be one out there that will be fairly quick to get working?
Any help, ideas, or suggestions no matter how small will be greatfully accepted!
Thanks
Tim
|
|
|
|