|
Like everyone else, I would question why this is not a class. That doesn't answer your question, however. If you do indeed need a struct...which indicates you need it to be allocated on the stack, I would do something like the following (this might not be exact...havn't used stackalloc in a long time):
public struct ChangeRec
{
public ChangeRec(byte modeSize)
{
mode = stackalloc int[modeSize];
}
public DateTime LastTimeStamp;
public int Last;
public int[] mode;
}
|
|
|
|
|
Thanks for all your inputs, I've got it working as a class. I still don't know how to make this an array using this structure. What I need is an array of 200 records with each record having the structure as originally shown and guidance on how to actually use it.
|
|
|
|
|
I want to know if I can inherit a class and then make it so one of the members that is inherited is not visible. My reason is that on top of memory issues, I don't want the empty member because i am going to use a list of members of the inherited class as a datasource of a gridview and if i have the extra member, it will appear on the gridview. I am up for other suggestions on how to deal with this problem.
|
|
|
|
|
bfis108137 wrote: My reason is that on top of memory issues
You can't fix this, and if the object is empty, the memory usage is negligible anyhow.
bfis108137 wrote: and if i have the extra member, it will appear on the gridview
Only if you make the gridview auto generate column s
bfis108137 wrote: I am up for other suggestions on how to deal with this problem.
Create an interface that only exposes the items you want to see, and then bind to a collection of that.
You can't make a property on the base class disappear.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello everyone,
Suppose I have the following XML file, I want to use XPath query based technologies to iterate all attributes for all rules nodes and all attributes for each sub rule nodes (under each rules node).
Could anyone provide some pseudo code please? I know how to query rules and related attribute but do not know how to loop inside embed node rule under each rules node.
<Abc>
<rules name="USA">
<rule foo="123" goo="345"/>
</rules>
<rules name="CAN">
<rule foo="321" goo="543"/>
<rule foo="321" goo="234"/>
</rules>
</Abc>
thanks in advance,
George
|
|
|
|
|
Suppose you have the following to query the rules nodes:
XmlNodeList rulesNodes = myDoc.SelectNodes("//rules");
Then, in order to loop the rule nodes:
foreach (XmlNode rulesNode in rulesNodes)
{
XmlNodeList ruleNodes = rulesNode.SelectNodes("rule");
foreach (XmlNode ruleNode in ruleNodes)
{
....
}
}
Hope this helps.
|
|
|
|
|
Thanks Le Centriste,
For this statement -- "myDoc.SelectNodes("//rules");", XMLDocument class does not contain a method called SelectNodes. Any comments?
regards,
George
|
|
|
|
|
George_George wrote: XMLDocument class does not contain a method called SelectNodes. Any comments?
Yes it does[^]
|
|
|
|
|
Sorry, Le Centriste!
My typo.
regards,
George
|
|
|
|
|
George_George wrote: For this statement -- "myDoc.SelectNodes("//rules");"
How did you created the XMLDocuments?
XmlDocument xmlDoc = new XmlDocument();
Now Check xmlDoc.SelectedNodes() is there or not ?
cheers,
Abhijit
|
|
|
|
|
Thanks Abhijit!
My typo in my code before.
regards,
George
|
|
|
|
|
George_George wrote: XMLDocument class
What XMLDocument class George? You have provided ZERO information about your development environment.
I see this year is going to be like last year with you eh?
led mike
|
|
|
|
|
Thanks led mike,
Found it out.
regards,
George
|
|
|
|
|
Try This one
XPathDocument doc = new XPathDocument(XmlFilePath);
XPathNavigator XPathnav = doc.CreateNavigator();
XPathExpression expr;
expr = XPathnav.Compile("/Abc/rules");
XPathNodeIterator XpathIterator = XPathnav.Select(expr);
try
{
while (XpathIterator .MoveNext())
{
XPathNavigator IteXPathnav= XpathIterator .Current.Clone();
Console.WriteLine("name: " + IteXPathnav.Value);
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
This is For Further Study[^]
cheers,
Abhijit
|
|
|
|
|
Thanks Abhijit,
Your code works good. But it only has one loop, but what I need is a loop inside another loop for the XML structure.
regards,
George
|
|
|
|
|
Please Read These
Ref1[^]
And
Ref2[^]
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
I created a DLL (class library) on C#.NET (2005) and want
to use it as an ActiveX control on a web page (html).
I have checked the box for Make "assembly COM visible" in the
project properties before I build the DLL. Code does do much,
here is my C# code for ctrl
namespace MyActiveXctrlLib
{
public partial class MyUserCtrl : UserControl
{
public string setName
{
set
{
txtName.Text = value;
}
}
public MyUserCtrl()
{
InitializeComponent();
}
}
}
here is my HTML
<title>Untitled Page
<object id="myControl1" name="myControl1" classid="MyActiveXctrlLib.dll#MyActiveXctrlLib.MyUserCtrl" width="288" height="50">
function doScript()
{
myControl1.setName = frm.txt.value;
}
on button click doScript(); is executed .
it sets the setName property of myControl1 i.e. WinForm control.
this code working successfully on IE 7.0 machine having .NET installed on them
but is not working on Machine those dnt have .NET installed on them.
not checked on IE 6.0.
Thanks in advance .
DaTtA
way2datta@gmail.com
|
|
|
|
|
Dattatraya Kale wrote: Subject: Run .NET ActiveX control on IE 7.0 machine that doesnt have .NET installed.
This is crosspost. You have already put the same question in asp.net forum.
cheers,
Abhijit
|
|
|
|
|
Was it really necessary to spam 5 forums with the same question??
Don't do this again. It's considered very rude and will not get your question answered any faster.
|
|
|
|
|
hello
guys, anyone know how to do mapping file for this? For example:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="ThinkFundamentals.Util.Security.Person, ThinkFundamentals.Util.Security" table="Person">
<id name="Id" column="Id" type="Int64" unsaved-value="0">
<generator class="native" />
</id>
<property name="FirstName" column="FirstName" type="String(50)" />
<property name="MiddleName" column="MiddleName" type="String(50)" />
...
<!-- how to map this to ObjProperties table? -->
<property name="ObjProperties" type="Util.Object" ??? />
</class>
</hibernate-mapping>
There's a table named "ObjProperties", schema for example:
Id int
PersonId int /* references */
PropertyName varchar(50),
PropertyValue varchar(50)
...
And class "Util.Object.ObjProperties" is NOT a collection class, but it contains one.
class ObjectProperties
{
... other properties ...
Hashtable _properties = new HashTable(); << See, that's the property collection.
...
}
I got a feeling this setup is not very nHibernate-friendly?
Thanks!
dev
|
|
|
|
|
public class MainClass
{
public virtual long MainKey {get; set;}
public virtual SubClass SubInstance {get; set;}
public class SubClass
{
public virtual long SubKey {get;set;}
}
}
can be mapped as:
<class name="MainClass" table="Main">
<id name="MainKey" column="MainId" type="Int64">
<generator class="identity" />
</id>
<many-to-one name="SubInstance" class="MainClass+SubClass" Column="SubId"/>
</class>
<class name="MainClass+SubClass" table="Sub">
<id name="SubKey" column="SubId" type="Int64">
<generator class="identity" />
</id>
</class>
So you need to use a plus(+) sign.
(I believe you have to use a dollar ($) sign for this in java hibernate)
|
|
|
|
|
Thanks but you're late (I don't use nHibernate no more!)
(But still thanks and voted 5 for ya)
dev
|
|
|
|
|
Hello everyone,
Support I am using str1 = str2 statement, both str1 and str2 are type of string.
Then, suppose str1 is hold by thread 1 and str2 is hold by thread 2. My question is whether operation (for example, tryu to change content of the string, toupper, tolower, replacement) on str1 (from thread 1) and operaton on str2 (from thread 2) are thread safe?
My idea is it is thread safe, since even if str1 and str2 are pointing to the same string instance, but as string is immutable, i.e. each operation which will change the content of the string will make a new string. So, it is thread safe.
Am I correct?
thanks in advance,
George
|
|
|
|
|
A quick check on MSDN[^] would show you that the string class as a whole is thread safe.
|
|
|
|
|
All operations in string class is thread safe?
regards,
George
|
|
|
|