|
Ummm... what? It's hard to read that code; put it in pre tags (select it and click code block ).
thenutz72 wrote: It's like you can have reference behaviour through functions that you cannot have WITHIN the function.
C# (.net) is all about references.
thenutz72 wrote: is forever unlinked
I don't know what that's supposed to mean.
thenutz72 wrote: way to do something more like
No, that's silly.
|
|
|
|
|
This really doesn't make any sense to me.
What does this even mean?
thenutz72 wrote: m_Myclass = ref objIn;
|
|
|
|
|
thenutz72 wrote: It's like you can have reference behaviour through functions that you cannot have WITHIN the function.
Pretty much everything is done by reference:
MyObject foo = new MyObject();
foo is a reference to the object created by the constructor. When it gets used it is automatically de-referenced, see this[^] for the c# boxing and unboxing model. When you pass an object to a method it is passed as a reference by default, you have to tell the method if you want it passed by value.
If you need pointers you have to use unmanagedunsafe code, where pointers are available, but in C# you rarely need it. I've being doing this for 10 years, and the only time I had to use pointers was during some interop work I was doing. Oh and a another time after I'd just graduated using c++ and didn't know how C# really worked, which was a bit embarrasing
Finally, please tag up your code with <pre> , it makes it easier to read. Otherwise you'll get responses of varying degrees of snottiness.
[edit]: When I said unmanaged code, I of course meant unsafe code. Better have a nice nap and a cup of tea, I'm getting old!
|
|
|
|
|
Thanks Kieth,
But in my code examples you'll see the ref keyword does act like a pointer to an object. Where as the assignment operator just assigns a reference. In the former, there are two variables with the same address. The latter, two variables that only point to the same reference.
Use of the new keyword in each scenario will confirm the difference.
I just find it odd that a function parameter can make use of pointers to objects but there's no way to duplicate that behaviour inside of a function. I was able to use unsafe code and pointers to primitive types to share addresses across multple variables. But was unable to do the same with a class/object instance.
|
|
|
|
|
You still haven't explained your question clearly.
|
|
|
|
|
First, in your code, the ref keyword is redundant, the reference pointer is passed round on objects by default, not the value itself.
Second, I'm still really not clear on your question.
private MyClass
public void MyFunction(MyClass objIn)
{
m_MyClass = objIn;
}
public void SomeOtherFunction()
{
m_MyClass = new MyClass()
}
public void Main()
{
MyFunction(new MyClass());
SomeOtherFunction();
}
Which language are you used to using and what exactly are you trying to achieve? If you need pointers you are probably going about things the wrong way in C#.
|
|
|
|
|
Unsafe code?
unsafe
{
int i = 1;
Console.WriteLine((long)&i);
}
Explained on MSDN[^]
I are Troll
|
|
|
|
|
I am not sure if I understand what you want to accomplish. I guess you could try the out keyword instead of the ref keyword.
|
|
|
|
|
How can I encrypt the entire App.config instead of encrypting just the aaSetting or ConnectionStrings only?
|
|
|
|
|
There is an article here that talks about this.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
It sounds like you don't want to use app.config at all*; find another solution.
* I write my own config files.
|
|
|
|
|
I love it but I don't want others to go, open it and play with the data there!
|
|
|
|
|
That's like saying you love your girlfriend, but don't want others to... oh, wait, maybe that's not a good analogy.
|
|
|
|
|
is it possible to compile the App.config withing the EXE output or as a separate DLL? will I still be able to read and write to the appSetting in this case?
|
|
|
|
|
Hi,
I am new to C shrap. I need help to design s software to move object in window. there can 4-5 object which will move in window and we can use mouse to catch all tht object. hope anyone will help me to do tht.
|
|
|
|
|
Hi,
you should learn to look around; make Google your friend, and use the CodeProject search facilities. Here[^] are some results.
|
|
|
|
|
windows forms have a property named Location. By changing it you can move objects in the window.For example to move a button in the screen you say:
yourButtonName.Location = new Point(newX, newY);
|
|
|
|
|
So I've set my grid to allowReorder ,
this causes persistence on the grid order but once the program is restarted it goes back to default
can someone let me know how I can save a user's re-order preference.
Thinking it can be a property? If not maybe build a method to take care of this
|
|
|
|
|
In your DataGridView look at the ColumnHeaderMouseClick event. You can gather DataGridView1.SortedColumn.Index to know which column is being sorted on and DataGridView1.SortOrder to see if ascending or descending. Then next time you refill the grid sort on that column and order.
|
|
|
|
|
I think he was asking about the order that the columns appear, left to right.
|
|
|
|
|
Ugh, that's what I get for not reading thoroughly.
|
|
|
|
|
|
As piebald suggested persist the order for each user. I use XML and store that sort of thing in the users application data folder. ASP would use a cookie.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
yes I persist on columnheaderclick.
So it looks like I would have to save the column header index when user navigates from that specific panel.
question is: (XML is going to be best option)
each column will have an index.. on build the grid builds the columns in order to the columns index.
what columnheader property is this and how would I go on to save and read from xml to populate these index #s
|
|
|
|
|
I use xml in this article[^]
You can set the column index at runtime or construct the DGV from code or you can reorder the underlying data source to reflect the column choice. Lots of choices.
Never underestimate the power of human stupidity
RAH
|
|
|
|