|
Yes this is what I am currently learning. Sorry I am not an expert yet.
Lucy
|
|
|
|
|
Lucy_H85 wrote: Yes this is what I am currently learning
So am I. I doubt I will ever stop learning.
Lucy_H85 wrote: Sorry I am not an expert yet.
Neither am I, no need to apologize.
|
|
|
|
|
Ok so I am confused.
What happends memory wise when I pass an instance of a class as a method parameter, for e.g.:
public class ClassA
{
}
public class ClassB
{
public string GetClassName(ClassA classA)
{
classA.OtherMethodClass();
return classA.ToString();
}
}
public class ClassC
{
ClassA a = new ClassA();
ClassB b = new ClassB();
string x = b.GetClassName(a);
Console.WriteLine(x);
}
Now does a new object get created in memory when I pass the class instance? Or would any changes made to the method parameter would also effect the actual object? Just need some clarification.
Thanks for your help.
|
|
|
|
|
You only pass a reference to the object.
Objects are never copied in .NET unless you specifically copy them.
---
single minded; short sighted; long gone;
|
|
|
|
|
So if I make any changes to the object passed through the method parameter, those changes will also effect the actual object?
public class ClassA
{
public ClassA()
{}
public string Color = "orange";
}
public class ClassB
{
public ClassB(){}
public string GetClassName (ClassA classA)
{ classA.Color = "red";
classA.OtherMethodClass();
return classA.ToString();
}
}
public class ClassC
{
public ClassC()
{
ClassA a = new ClassA();
Console.WriteLine(a.Color.ToString());
ClassB b = new ClassB();
string x = b.GetClassName(a);
Console.WriteLine(a.Color.ToString());
a.Color = "Green";
}
}
|
|
|
|
|
Yes it will write "red".
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
And if you pass a ValueType like int, DateTime, ... then a copy is passed to the method, as long as you do not mark them with ref or out. The copy is then pushed to the Stack where the method gets it from.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Guffa answered your question correctly for class instances: passing a class instance to a method will *NOT* copy it; you're passing a pointer to that instance.
As Urs mentioned, if you pass a struct instance (say, a System.Int32, a DateTime, or your own custom struct), it *WILL* pass a copy of the struct instance to the method.
In summary: class instances are passed by reference (no copying going on), and struct instances are passed by value (copying).
As a side note, if you do want to pass values by reference, you can do so using the ref keyword.
|
|
|
|
|
Does anyone know of a cipher that will convert/encrypt any printable characters into all upper-case letters? Essentially I would like to be able to convert the output of a DES encryption, which can contain numbers, letters or special characters, into all upper-case letters. Does anyone know of any code, no matter how simple, that can provide that function?
Thanks...
|
|
|
|
|
Decrypt it. Convert it to upper case. Re-encrypt it.
You cannot convert it to upper case while it is in its encrypted state.
|
|
|
|
|
do you mean convert the crypttext into something that looks like ABLKSJFHUIWKLDHALSDHQWE... or to capitalize the contents of the encrypted text while keeping it encrypted? The later as the other poster mentioned is impossible. The simplest way to do the former would be to map each 8 bit value onto one of the first 256 2 upper case character pairs. eg
0x00 = AA
0x01 = AB
..
0x1A = AZ
0x1B = BA
...
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
dan neely wrote: do you mean convert the crypttext into something that looks like ABLKSJFHUIWKLDHALSDHQWE...
Yes, and your suggestion should work fine for what I want to do...
Thank you.
|
|
|
|
|
Or you could try UUEncoding, which isnt exactly what you have requested, but at least you wont be reinventing the wheel.
|
|
|
|
|
Although not strictly letters, maybe a simple hex representation is sufficient,
i.e. replace each encrypted byte by two characters in [0-9A-Z].
byte.ToString("X2") would do that for you.
And byte.Parse(string, NumberFormat.HexNumber) would undo it.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
If acceptable that'd be a better solution than mine, but I suspect the all uppercase letter requirement is due to interfacing with a crufty legacy system not new development that is potentially changeable.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
I thought the best avilable way to ensure security for my software is to access the hard disk serial number of the end user. I know this was have alot of problems, but I have no better. I need to know the easest way to acheive this effectivly, and if there is more effective way?
Yasser Abu Elmakarem
|
|
|
|
|
The "best" way for you may not be the best way for your customer.
I for one will not buy a license that is fixed to a specific piece of hardware, since
as soon as my hardware needs a replacement, my software needs a new license resulting
in unnecessary hassle and cost.
I like the concept of dongles, i.e. a small USB device that holds the key for the
licensed app or apps (Google for "software protection", Wibu, Safenet, and others).
As a customer I can now move may app+key to whatever machine a like, but I can run it
only on the machine that has the dongle.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I want to open my executable file on a system has no (dot net framework) istalled on it. Should I install dot net framework every system I copy on? Please I need a solution
Yasser Abu Elmakarm
|
|
|
|
|
There are some very expensive applications which will "bake" the .Net runtime into your executable so they will run without .Net being installed. However, it is fairly trivial to include the .Net redistributable as a dependency in an installer so that it will be installed if it is not present.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Can you help me about textbox control?
I am a student from Macedonia who is new in c#.
The problem is
I am enter number 54324 in textbox control.
when I press button "count"
I want label.text to get this value from textbox= 5+4+3+2+4
I need this help immediatly so if you can, help me
Thank you!
kpp
|
|
|
|
|
You will need to extract every character from the textbox, convert it to int and add to a variable which will be counting sum of the digits. You can access individual characters like this: mystring[i]. Use Int.Tryparse to convert it to integer.
|
|
|
|
|
I will help yopu a bit, but its homework and you need to do it yourself.
convert to string
split string
convert each character to number
add numbers
you may want to use a loop.
|
|
|
|
|
Thank you for your support & help, I am new in c# and, I already solve this problem, sitting 23 hours in front of my machine!
I use function substring!
I would be like this:
for(i=0;i<textbox.length;i++)
{
sum="sum" +="" textbox.substring(i,1);
}
thank="" you="" again,="" but="" my="" application="" still="" is="" not="" finished.
can="" i="" ask="" for="" help,="" next="" time,="" when="" needed?
sorry="" bad="" english="" in="" some="" parts="" the="" text!
ciao...="" now="" maybe
=""
<div="" class="ForumSig">kpp
|
|
|
|
|
i have a datagrid and its column name is Session.
I have a table in that 3 fields are there.They are Morning ,Evening,and Afternoon.They are checkboxes.These fields are saved as YES/NO in database.I want to retrieve data from database to datagrid in a single cell like Morning ,Evening,Afternoon .........I want to retrieve ColumnHeader in table instead of checkbox
if u need more clarification pls ask me?
|
|
|
|
|