|
forgive me - I'm new to c#
public struct lookupOjbect
{
string fieldvalue;
public lookupOjbect (string fieldvalue)
{
this.fieldvalue = fieldvalue;
}
}
lookupOjbect lookupObjectRow = new lookupOjbect();
When I want to assign a value to this object then 'fieldvalue' doesnt show with intellisense. e.g. lookupObjectRow.fieldvalue - doesnt show!
|
|
|
|
|
it is because fieldvalue is private.
Try
public string fieldvalue
though that is not great oop, and most thing use properties to get around that and keep encapulation, e.g.
private string fieldvalue;
public string FieldValue
{
set { this.fieldvalue = value; }
get { return this.fieldvalue; }
}
|
|
|
|
|
|
Remember that changing the values in a struct type only affect that particular instance as it is a value type.
If you are planning on implementing a Get / Set accessor, you may want to think about using a class instead.
|
|
|
|
|
The Catalyst wrote: Remember that changing the values in a struct type only affect that particular instance as it is a value type.
And so what happens in a class if it doesn't "only affect that particular instance"?
The Catalyst wrote: If you are planning on implementing a Get / Set accessor, you may want to think about using a class instead
Why would a class be better in this instance? What is wrong with putting Get/Set accessors on a struct?
|
|
|
|
|
Colin Angus Mackay wrote: And so what happens in a class if it doesn't "only affect that particular instance"?
It's the old Refference / Value type behavior. I think i worded it badly.
Any change made to a class is reflected through all refferences, making changes to a struct only changes the one you are changing in the local context. (Barring special circumstances)
Colin Angus Mackay wrote: Why would a class be better in this instance? What is wrong with putting Get/Set accessors on a struct?
I've never seen a Get / Set in a struct, at least, not in the standard CLR libraries. Tho i suppose there must be some, i can't imagine a use for them; All the com interop structs use public fields.
From what i've seen, everything gets set in the ctor. and accessed through read only properties.
|
|
|
|
|
The Catalyst wrote: I've never seen a Get / Set in a struct, at least, not in the standard CLR libraries.
Actually, virtually every struct I've seen in the BCL uses properties: Point, Size, Rectangle, to name a few, all expose their data via properties.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
True, but they are all read only. None of them implement a set method, you have to create a new object if you want to use different values.
|
|
|
|
|
The Catalyst wrote: True, but they are all read only. None of them implement a set method
That's wrong. Look at the Point.X for example. You can set it.
|
|
|
|
|
Still, pretty pointless.
|
|
|
|
|
The Catalyst wrote: True, but they are all read only.
Have a look at Rectangle.Width, Height, Size, and others.
|
|
|
|
|
The default accessor property for a field in C# is private, therefore it would only be accessible internaly, and not appear on intellisense. Just wack public infront of it.
|
|
|
|
|
public members are a crime
keep fieldValue private.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
If a tree drops in the forest...
|
|
|
|
|
I have written code for report in Form_Load event handler as under:
System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter("Select * From Customers",
"server=pc1;database=northwind;trusted_connection=true");
System.Data.DataSet ds = new DataSet();
adapter.Fill(ds, "Customers");
CrystalDecisions.CrystalReports.Engine.ReportClass rpt1 = new CrystalDecisions.CrystalReports.Engine.ReportClass();
rpt1.SetDataSource(ds.Tables["Customers"]);
CrystalDecisions.Windows.Forms.CrystalReportViewer rptviewer = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
rptviewer.Dock = DockStyle.Fill;
this.Controls.Add(rptviewer);
rptviewer.ReportSource = rpt1;
but it gives me the following error:
Unable to find the report in the manifest resources. Please build the project, and try again.
Can someone help how to generate report in this way?
Thanks for consideration
|
|
|
|
|
hi all,
i have a windows form lets say 'myform'.
i check on myform's load if there is a previous instance of 'myform' running or not.
> if a previous instance runs, then i display an error message and close the secondly opened copy.
but after closing secondly opened instance, i dont know howto maximize the first copy of 'myform' which was minimized on taskbar ?
do u know howto maximize & bring to front the previous myform or at least to blink it like msn messenger ? (when a message received)
thanks in advance,
bye.
|
|
|
|
|
|
|
Hello Frieds,
I just want to ask you that, How to split the string by another string.
Take ex.-
string tosplit = "10***3*2**5";
string delim = "***";
now o/p should be split1 = 10
split2 = 3*2**5
Thanks in Advance.
Rahul Kulkarni.
|
|
|
|
|
Try this:
string[] Parts = tosplit.Split("***", StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
Firstly Thanks for your response.
You have suggested "StringSplitOptions".
But i think it is not in the framework-1.1
Can you suggest any other solution.
Rahul Kulkarni
|
|
|
|
|
RahulRKulkarni wrote: But i think it is not in the framework-1.1
You're right, it's new in Framework 2.0.
Perhaps you can use IndexOf("***") in combination with Substring.
|
|
|
|
|
Use a regular expression:
Regex re = new Regex(@"\*\*\*");
string[] splits = re.Split(tosplit);
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
I know dictionaries don't accept duplicate keys, but hashtables are inherent within dictionaries. If the answer is yes, then what data structure could I use?
|
|
|
|
|
honeyman_can wrote: what data structure could I use
One possibility is a hashtable whose values are ArrayList s list of values. When you try to add a duplicate key, append the key's value to the existing list.
/ravi
|
|
|
|