|
Wow. If you are quite new to C# this is very ambitious (to say the least).
Good luck...
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
It's about a year that I'm new to C#! I never encountered any serious problem unless I wanted something that no one thought of before in Microsoft Visual C# team. I have been coding in C++ for some years mostly in MFC.
Now when making a new design I believe language is not much of a problem. This problem existed in MFC and now it exists in MS windows forms. I don't like using events for every task. I just decided to test some new ways of doing that. Most probably someone already did that. Maybe I have been too lazy not to search enough or a bit unlucky(I searched actually.)
Thomas Weller wrote: Good luck...
Thank you and thanks for the help.
"In the end it's a little boy expressing himself." Yanni
modified on Wednesday, November 26, 2008 6:11 AM
|
|
|
|
|
I think it's more accurate to say that everything in .Net is a pointer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Well, when you think of a pointer simply as a memory address, then of course you are right.
But normally, when programmers say 'pointer', they refer to a concept like the one known from C/C++. And this simply does not exist in .NET (at least not in the safe part of it).
(edited to correct a typo...)
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
modified on Wednesday, November 26, 2008 5:54 AM
|
|
|
|
|
I think that's only true for reference types. Values types (for example) have the actual values pushed onto the stack when passing them as parameters. I think they're handled identically to value types in C++.
|
|
|
|
|
You can access a pointer in C#, but you almost never need to. Any class is passed by reference, so you can have more than one reference to the one object, as you would with a pointer. An int is a value type, so this does not hold true. You could use int?, I assume that is a class, not a struct (structs are passed by value, not by reference ). The other thing you can do is use delegates to tell clients when a value changes, to get the same effect.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
AFAIK, int? is equivalent to NotNullable<int></int> , which is a struct.
|
|
|
|
|
It's exactly the other way round.
The int data type is a value type (i.e. a struct), which means that it is not nullable by design.
int? is a syntactical enhancement that is equivalent to Nullable<int> .
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Sorry, I wrote the "Not" by mistake .
Nullable<int> is a struct.
|
|
|
|
|
Christian Graus wrote: I assume that is a class, not a struct
No. It is a struct[^]
|
|
|
|
|
I agree with Thomas. This is rather ugly design, and totally against all the principles of OO.
There are pointers in C#, you just have to use the unsafe[^] keyword before you use them. (And like Thomas say, for good reason, they are not encouraged and can cause lots of problems)
In C# types fall into two categories. Value types (structs) and reference types (classes). Reference types are kind of like pointers, when you pass them around, only the reference to the type is passed around and stored on the stack. The actual type is stored once in the heap.
You could do this:
public class AClass
{
private BClass _b;
public AClass(BClass b)
{
_b = b;
}
public void SomeFunc()
{
_b.X = 20;
}
}
public class BClass
{
private int _x;
private AClass _a;
public BClass()
{
_a = new AClass(this);
}
public int X
{
get
{
return _x;
}
set
{
_x = value;
}
}
}
Here, class A holds a reference to the instance of class B, so can call the public property on class B to get/set the value of B's variable.
Simon
|
|
|
|
|
Thank you. Very helpful information. As you mentioned this has a design issue. I'm wondering for a better solution.
Thank you again for the helpful information.
"In the end it's a little boy expressing himself." Yanni
|
|
|
|
|
Pass by reference is supported in C# and VB.net. So I guess you can use that. Just search for their sample usage in MSDN
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
I know pass by reference. The problem was to hold the reference and change it's value later on. It looks like as I thought it's only possible by wrapping a struct type inside a class and sending reference to that class and using it to access the struct inside or sending a reference to current class that this struct is a member of which is another way of saying same statement.
From kind help of others I conclude it this way: To store for later access to a state of another class, we need to have that class.
If I was using my brain before asking the question, it was obvious. C# keeps track of references to objects. If someone uses internal data of an object without accessing a reference to that object how can garbage collector find out that it has to keep an object alive even if no one has any reference to that object. No reference = removing it and now a reference to a type inside an object that does not exists is what we ended up. That maybe why we must use class to access it's members. Also as stated earlier it's absolutely a bad design.
Thanks for the help anyway.
"In the end it's a little boy expressing himself." Yanni
|
|
|
|
|
Technically it is possible using boxing (http://www.csharphelp.com/archives/archive100.html[^]).
You can use an object for your local variable, and assign any value type to it. If you pass this object as a parameter, its reference (address) is passed, so the called method can change the local variable of your class.
|
|
|
|
|
hi,
My goal is to create backup for a directory every 5 minutes.
But here is the trick, this backup needs to be done during my working with files on this directory.
which means that I would probebly have a word document open while the directory is beening backup.
so far every move that I've made I recived "cann't access file".
Please help...
tnx
|
|
|
|
|
Correct, you can't copy a locked file. No way around it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
yes, you can't access a locked file.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
|
tnx but my problem is bigger than this.
I need to buckup the whole folder including other files that might be in use (xls,spss & etc.)
it's a pain. but tnx anyway
|
|
|
|
|
Hey uh, i have a project and its considered as a thesis project in our school. My project is an automatic controlling model for monitoring and triggering.
A webcam or any camera will be attached to monitor object in a two dimensional frame with x and y axis. My problem here is, for initial run of the program(the camera is already in front of the frame) the camera will monitor if there is a change in the plane, like for instance the frame is a white board and I put a dot in the white board, the program would determine the coordinates of that dot(.) in the x and y axis of the plane in front of the camera. And once that coordinates is located, a pointer like a laser pointer attached to stepper or servo motor that is connected to the (parallel) port of the computer, will point to that coordinates computed by the program.
my specific problems are:
1. how would the program know the coordinates of the interrupting object?
2. how would the pointer that is attached to the stepper motor point the coordinates of the plane in front of the camera?
these are my major problems.
My adviser told me that the camera will be used as an actuating device. But I would ask for a better actuating device to monitor an interrupting object on the frame. Please do advise or help me I'm just a 4th year student and I don't even have a background of device interface programming, and I am also a beginner in C#.Net or VB.Net language please do help me. I can't graduate without this. Please
|
|
|
|
|
Tiunay wrote: I can't graduate without this. Please
Sorry, but if this is above your technical skills, you shouldn't graduate - simply because you don't fulfill the requirements. (Or maybe the requirements are not appropriate. Don't know and don't care...). Do your homework!
This is not a free-of-charge coaching place!
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
hey sir uh, no offense please
but its not about the homework or unaccomplished material or something
maybe its not like your school but uh let me tell you that its not like any school in US that spoon feed students. I'm here in the Philippines and our school is a type of school that doesn't spoon feed students. It mean that, our challenge that is the point of our studies, just how we knew the language in C++ or Java is also the same. We were given a problem and they let us decide whatever we do just to show them that the program is working properly.
It is hard for me to use C or Java for that specific problem that is why we are obliged to study other language in just a short period of time. The strategy of our school is to guide the students only and this is not the same in US that trains even a simple logic to students.
What I'm trying to Please is Only a GUIDE and ADVISE.
Please if you don't like to help me or give me some guidance, please be advised to please don't comment anymore. You'll just waste you time.
What I'm seeking is help not a Sermon.
Thanks.
modified on Wednesday, November 26, 2008 4:32 AM
|
|
|
|
|
Read my image processing articles for ideas on how to look through a bitmap to work out if an area is black instead of white.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|