|
You've not instantiated the List anywhere. This has nothing to do with it being inside a struct - the same would have happened if your list was inside a class.
You can fix this by first creating the List.
testStruct aTestStruct = new testStruct();
aTestStruct.sList = new List<string>();
aTestStruct.sList.Add("test");
However, a few pointers
0.1) Naming convention for C# would instruct that your property is called List instead of sList .
0.2) Be careful using structs, they have some hard to understand facets - if in doubt use a class.
0.3) Strictly speaking, a List should generally not be exposed by a public property. Consider whether the struct/class should instead expose just the interface, such as an Add method to add to an internal List.
|
|
|
|
|
struct s are meant for small value types. Both List<T> and string are reference types, and their size could potentially be very large, so I would never use them inside a struct .
|
|
|
|
|
But since they are reference types, the struct would only contain the reference..
"The actual thing" is included in the struct if it's marked ByValArray or ByValTStr or when it is a fixed size buffer[^] (I've never actually seen one of those)
|
|
|
|
|
True, I hadn't actually considered that!
I still don't like it due to the mutability implied by using a reference type inside a struct, especially with List<T> as the contents would be mutable even if the exposed list wasn't. A ReadOnlyCollection<T> would be OK I suppose, something like this wrapper...
public struct ExampleStruct
{
private List<string> list;
public ExampleStruct(IEnumerable<string> strings)
{
if (strings == null)
list = null;
else
list = new List<string>(strings);
}
public ReadOnlyCollection<string> List
{
get
{
if (list == null)
return null;
return list.AsReadOnly();
}
}
}
|
|
|
|
|
A field in a struct is mutable though, so I'm not sure what you mean..?
|
|
|
|
|
Of course, but they are generally exposed only by a read-only property. It's rare and generally not recommended to have a property with a setter or to expose the field directly in a struct.
|
|
|
|
|
I have my vs2008 c# project compiled,
when i install on win Vista, it runs fine
but does not run on win XP SP2.
please can some help me out.
thanks alot.
|
|
|
|
|
Is installed on your Windows XP system the version of the .NET Framework that your application is expecting?
|
|
|
|
|
I used VS2008 and .net 3.5 for the building of the app
on Win Server 2003 Enterprise Edition.
The .net 3.5 will not install on Win XP sp2, so i rebuild with .net 2.0
and i have installed .net 2.0 on the system
|
|
|
|
|
If you had a .NET version problem, I'd expect an error 0135.
Error 0x7b may mean: The filename, directory name, or volume label syntax is incorrect.
Could be many things, e.g. you're trying to access one of the special folders (such as Users or "Documents and Settings") without going through the proper channels (Environment.SpecialFolder). Proper try-catch and Exception reporting would take care of the details.
|
|
|
|
|
But the same project when installed on Win Vista does not generate any errors.
thanks.
|
|
|
|
|
I have found Solution to it,
I formatted my Win XP sys and reinstall the OS.
everything is working fine now.
Thanks to Everyone.
|
|
|
|
|
It's a so drastic as good solution
|
|
|
|
|
Hi,
I have to validate the control in server side and have to find which value is wrong. Ex im passing user name and password. if password is wrong it should find only the password is wrong not the user name.. Please help me..
|
|
|
|
|
Are you in correct forum?
Go here[^]
rahul
|
|
|
|
|
Hello everybody,
I am doing a application which needs to communicates with a DCOM server. I created a .NET wrapper using tlbimp.exe and referenced it in my C# program.
I then create an Object from my remote server using Activator.CreateInstance("Objectdd.obj","ServerNAME"); and cast the returned object to the correct type in the .NET wrapper class.
Until here everything is working fine, I can call method on my object from C# and the call is correctly executed on the remote machine.
The problem is, as soon as I try to connect to an event from C#, I got a System.UnauthorizedAccesException. This is strange because I can call every others method with no problems. I also tried my C# software on the server, using "localhost" as server address and I could connect to the event correctly.
Any ideas what's wrong ? Any security problems I am missing ?
Thank you,
|
|
|
|
|
|
usually when we open a cs file(by Double Click)it open in the vs2005 IDE, if no IDE is opened it will open one and show the file , but if an IDE exist then the file will be opened in the existing IDE.
But i want to open the .CS file through my application and always in a new IDE instance in a new process, because i want to keep tracking the process.
but when call the
process.start("devenv","filename"); it opens in an existing IDE if one exist.
what i want is to always open a separate IDE for my app.
any idea how to do this.
thanx in advance.
|
|
|
|
|
prasadbuddhika wrote: usually when we open a cs file(by Double Click)it open in the vs2005 IDE, if no IDE is opened it will open one and show the file , but if an IDE exist then the file will be opened in the existing IDE.
Yes, that's common behavior, because you are trying to open a file and not the application. you just double click on the visual studio icon, and it will open new IDE all the time, because there you are trying to open an application. now use the same code and don't pass the file name, I think it will open new IDE all the time.
Also, by reading your few previous posts. As suggested to you previously, just develop Visual Studio Add-in / Extension. and you will have access to everything you want in IDE. otherwise keep in mind that you cannot control some external process, that is already running, from another process. they are running in separate domain. unless the process supports RMI kind of functionality. Which Visual Studio IDE is not supporting. so instead of spending time on doing everything remotely. try to create in-process pug-ins and you will have full control.
|
|
|
|
|
You've been told not to do this. Now please stop. Replies to the threads should be done on the original thread.
|
|
|
|
|
Hi all,
Is there any way to hide the Y axis scale points on my Barchart? I wouldn't want to show datapoints for the Y axis.As i dont want to be seen by users.
Chart1.ChartAreas("ChartArea1").AxisY ??????
Is there any Property which ci could use to hide this scale points on Y axis?
Thanks for your time.
-- Modified Wednesday, October 6, 2010 11:05 AM
|
|
|
|
|
As you already know, Bar Chart is 2 Axis chart, so you cannot hide any of the axis, otherwise it will not plot the chart.
but you can make the Color of the Y Axis same as Background color of the Chart Area. So that It's there but not visible (kind of).
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor = "Your background color";
Chart1.ChartAreas["ChartArea1"].AxisY.LineColor = "Your background color";
Chart1.ChartAreas["ChartArea1"].AxisY.TitleForeColor = "Your background color";
Hopefully this should work...
If you have gradient background, this is not going to work.
Please Let us know, if you find out any other way to hide the Y-Axis
|
|
|
|
|
Thanks for your email.Its much appreciated.That is great point,what i wouldnt want to show is the scale points as they are Revenue points which users are not allowed to see.
The backcolor is white at the moment setting the forcolor to white wont show scale y axis.
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor="#FFFFFF"
Did i get it right?
|
|
|
|
|
kibromg wrote: Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor="#FFFFFF"
It should be
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor = System.Drawing.Color.White;
|
|
|
|
|
Thanks so much.
Sorry if you dont mind , I have another query.On my X axis for each scale points i have two bar graph.
One is the target for the day and the other one is a progreess bar which indicates as we approach to that target.
Lets say (x axis is Hours of the day)
for instance at 8:00am i have a target of $1000 and this is shown with one Bargraph. and i have another one which is an online realtime data that counts as persentage to this value.So at exactly 8:00am it will be zero percent and after few minutes it will climb up this point until the hour finishes. and at 9:00 there will be another datapoints on x axis may be £2000 and another progreess bar that shows the progress etcc..
$1000 is 100% target for 8:00am and another bargraph toshow what is achieved say $500 so it will be at 50%
£2000 is 100% target for 9:00am and another bargraph to toshow what is achieved say $4000 so it will be at 200%
How can i represent one bargraph $1000 and another one saying 50% for one datapoint in X axis?
Is it clear?
-- Modified Wednesday, October 6, 2010 12:37 PM
|
|
|
|