|
I tried as below
"../Descritpion" gives immediate parent description; "../../Description" gives grandparent's description. and so on..
for (int i = 0; i < level; i++)
{
temp+="../";
parent += book.SelectSingleNode(temp + "Description").Value;
}
I tried book.Select("ancestor::Entity"), as you suggested.
both are working fine. I think first one is not a good programming practice.
Thank you for giving me the link.
|
|
|
|
|
That looks familiar.
|
|
|
|
|
Hello,
I already figured out how to load another assembly from my C# application, and extract the resources embedded to that assembly. My problem is that I'd like to filter the resources by type, i.e. I want to get only text resources, but not icons and other stuff.
The code I use at the moment looks like this:
Assembly target = Assembly.LoadFile(filename);
string[] list = target.GetManifestResourceNames();
foreach (var listentry in list)
{
Stream resourceStream = target.GetManifestResourceStream(listentry);
var rr = new ResourceReader(resourceStream);
IDictionaryEnumerator dict = rr.GetEnumerator();
int ctr = 0;
while (dict.MoveNext())
{
ctr++;
string entry = dict.Value;
}
rr.Close();
}
How can I determine which kind of resource entry I currently get, i.e. if it's an icon, a text resource, or something else?
|
|
|
|
|
Hi,
I am designing simple application using C#. I want to know that, How may I use following oracle query into MS-Access?
Oracle Query is:
string strQuery = "SELECT * FROM ITEMS WHERE NVL(ITEMTYPE,'Z')='P' ";
Thank you
(Riaz)
|
|
|
|
|
Replace NVL to ISNULL. This should work.
Be an Eagle, Sky is Yours.
|
|
|
|
|
Also get rid of the NVL/ISNULL as it is not required in the query - all you are looking for is if ITEMTYPE is equal to 'p' and null is not equal to 'p'.
string strQuery = "SELECT * FROM ITEMS WHERE ITEMTYPE = 'P' ";
This just means that you are not carrying out an unnecessary calculation.
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
You can try this too:
SELECT it.* FROM ITEMS it
where it.ITEMTYPE =
case
when it.ITEMTYPE is null then
'Z'
when it.ITEMTYPE is not null then
'P'
end
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Which version of MS Access does that work in?
|
|
|
|
|
Hello Frnds i have been working for many days now but still i cant find out the way how i can automatically fill in the login details in a web page via an app which stores all the login details and as per the url entered in the web browser and it logins the user.Example if i have stored the userID of my yahoomail in the app and as soon as i open the yahoomail page it automatically enters the login details in it.Can any one help me out with it please
|
|
|
|
|
First thing, you should post this in ASP.Net.
Second, you can use cookeis to store your login credential on client side.
Be an Eagle, Sky is Yours.
|
|
|
|
|
why i can not call a static function with the object of the class. I mean if i write
public class sexp
{
public static int s;
public void count()
{
s++;
}
public static int disp()
{
return s;
}
}
class static
{
public static void main(string [] args)
{
sexp s=new sexp();
s.count();
console.write("{0}",sexp.disp());
console.readline();
}
}
Why i cannot write "s.disp() insteed of sexp.disp()??????????
modified on Thursday, July 21, 2011 8:23 AM
|
|
|
|
|
Basically that's just the way it works. That shouldn't be a problem though, because you can just make a nonstatic function whose only purpose is to call disp . (not always needed, but that way disp is still static so it wouldn't accidentally break other code which relies on that)
|
|
|
|
|
I don't see a static function (method) in there.
|
|
|
|
|
oh sorry. i done a mistake. i wrote public class int disp() but it is public static int disp().
|
|
|
|
|
I don't think this should even compile, the line
public class int disp()
is not valid.
The best things in life are not things.
|
|
|
|
|
yes u r right sir. i done mistake. i make disp() class but it was a static method.
|
|
|
|
|
*DBAU wrote: public class int disp()
Your code will not compile at all. Did you mean this?
public static int disp()
|
|
|
|
|
|
Hello.
I am still learning C# and as a new project, I wanted to write a simple chemical equation balancer, but dont really know where to start.
I am not asking for code, as I really want to have a go at this myself, so if I show my views below on how I would imagine tackling this problem, maybe someone could point me in the correct direction.
An example of a chemical equation, a simple one, would be...
H2 + O2 = H2O
Balanced, we end up with.....
2H2 + O2 = 2H2O
I was thinking of the following steps...
1) Parse the left side (reactants) into one string, and the right side (Products) into a seperate string.
2) Loop through the string looking for the letters representing the elements and the numbers to count how many we have
3) ** Havent got a clue how to manage this ** maybe use some kind of matriz to store all the values and then use logic to "balance" the equation.
Does anyone have any ideas or tips?
Thank you,
Regards,
Steve
|
|
|
|
|
Well, when you're balancing a chemical equation, all you're really allowed to do (If I remember my high school chemistry) is adjust the amount of each component, right?
So I think you need to do this in a recursive loop with three main steps:
Step 1: Figure out the amount of each individual element, subtract the two sides, and see how much you have to add on each side to balance it.
Step 2: Pick one of these imbalances and figure out which terms contain that element. Prioritize terms based on how many other elements they affect (If you need to increase Hydrogen, prioritize the H2 term above the H2SO4 term).
Step 3: For each of these terms (In order of priority), increase the amount of that term to counter the imbalance, then repeat this process with the modified equation (Using recursion, so you come back to try a different term if it fails).
There's probably a better way, but this is the first one that popped into my mind.
Example:
H2 + O2 = H2O
1) 2H + 2O = 2H + O.... Subtract and you see you need another O on the right side
2) There's only one term that contains O on the right (Only one term, period)
3) Increase H2O to 2H2O to add one more O. New equation is H2 + O2 = 2H2O...
1a) 2H + 2O = 4H + 2O... Subtract, and you now need 2H on the left side
2a) Only one term contains it (H2)
3a) Increase that to 2H2 to get the extra two hydrogens. New equation is 2H2 + O2 = 2H2O
1b) 4H + 2O = 4H + 2O... Subtract, and it's balanced, so return it.
Obviously a simple example.
|
|
|
|
|
Hi,
Thank you, this was pretty much what I was thinking.
Do you have any ideas of the best way to store and sort the terms?
i.e. Should I use a struct for the elements? etc
I am still a beginner so any advice is most welcomed.
Kind Regards,
Stephen
|
|
|
|
|
Well, if you want to keep everything organized, maybe something like:
Element class: Stores a certain quantity of one element (i.e. 2 x H)
- Symbol
- Quantity
FormulaTerm class:
- List/Array of Elements (Each with a quantity)
- Text representation (Taken from the original formula, so it would know to represent 2H,O as "H2O" - More important for complex formulas that could have the same element multiple times)
- Quantity ("2" for "2H2O")
* Methods to add to other FormulaTerms, and to extract Elements (Multiply Quantity by each Element)
FormulaSide class:
- List/Array of FormulaTerms
* Method to combine with another FormulaSide to find the imbalances
|
|
|
|
|
I would probably set this up as two arrays, operands (left side) and results (right side). The arrays would contain structures that have two elements. The first element would be the multiplier for the particular item, and a dictionary with the element symbol as the key and the how much as the value.
The Dictionary object has a sort method built in, but you'll probably want to write your own to meet the requirements for sorting the particular elements according the the standard rules of chemistry. For example S comes before O for SO4.
I hope you find this approach helpful. If you have any questions, feel free to ask.
Scott E. Corbett
Software Engineer/Analyst
|
|
|
|
|
H2 + O2 = H2O
...
2H2 + O2 = 2H2O
hmm...
here's what i'd try for a first attempt:
1. parse the equation into left and right: "H2 + O2" and "H2O"
2. break it into molecules. left side "H2" "O2", right side "H20"
3. break the molecules into elements, pay attention to the counts
4. put each element into a container that will hold a label and a count (multiset, maybe)
ex.
left side:
Add H (container has: H:1)
Add H (container has: H:2)
Add O (container has: H:2, O:1)
Add O (container has: H:2, O:2)
right side:
Add H (container has: H:1)
Add H (container has: H:2)
Add O (container has: H:2, O:1)
5. compare the two containers to see find the differences . in this case the only difference is that the left has O:2 but the right has O:1, so there's the imbalance.
to balance, you have to adjust the molecule counts to get the element counts right... which is probably a bit of work
|
|
|
|
|
Just my tuppenceworth, the other answers have been good.
There is a full balancing method here[^]. It should transfer to an algorithm easily.
For the data representation I'd use two dictionaries, one for the number atoms on the LHS, the other for the right. You can make the chemical symbol the key, but you might also like an element class, that way you can do other handy stuff like work out the molar mass of the products etc.
I actually think the formula parser might be the hard part, but not having worked on the problem fully I could well be wrong.
|
|
|
|