I went for static in get/set class and it worked fine Thanks very much for the easy solution SK Genius. Thanks to all for trying to help too. Cya
ipstefan
Posts
-
Get/Set for List<string> in C#</string> -
Get/Set for List<string> in C#</string>When I try to make foreach(string s in def_compare) Console.Writeline(s); It doesnt write anything.I guess the list is empty. I tried how you told me to: in class 1: DefCompareProperty df = new DefCompareProperty(); df.SetDefComp(def_compare); in class 3: public void SetDefComp(List<string> members) { lst = members; } And I still have an empty list in class 2.
-
Get/Set for List<string> in C#</string>Hi guys. I got a problem I cant find solution to anywhere over the internet..I might have missed something in my logic. <pre> class DefComparing:DefCompareProperty { public void DefCompare() { List<string> def_compare = new List<string>(); ********doing something to the list here****** DefCompareProperty df = new DefCompareProperty(); foreach (string s in def_compare) { df.SetDefComp(s); } } } </pre> Then I want to use the def_compare list in another class. <pre> public class Aliniere { public List<string> def_compare = new List<string>(); public void Aliniate() { ******doing some operations here**** DefComparing newdefcomp = new DefComparing(); newdefcomp.DefCompare(); def_compare = df.GetDefComp(); //Trying to get the list from that other class </pre> What I tried to do is make Set/Get properties for the list. <pre> class DefCompareProperty { private List<string> lst = new List<string>(); public List<string> GetDefComp() { return lst;
-
Remove duplicate nodes from xml using c#that worked out good for me..thank you... The code:<pre> XElement duplicate = XElement.Load("wnrom2.xml"); StringBuilder build = new StringBuilder(); Dictionary<string, string> dict = new Dictionary<string, string>(); foreach (XElement dup in duplicate.Descendants("SYNSET")) { build.Append(dup.ToString()); } dict.Add("a", build.ToString()); if (dict.ContainsValue(synsets.Descendants("SYNSET").Last().ToString()) == false) { synsets.Save("wnrom.xml"); synsets.Save("wnrom2.xml"); } </pre>
-
Remove duplicate nodes from xml using c#so the method works for not adding duplicates in a file? And how do you remove it the duplicate in the file.
-
Remove duplicate nodes from xml using c#I dont think it will really work. As I said to you the xml database has around 100.000 entries. What I wanna do is check if an entry appears 2 times in that database and remove the duplicates. I read the dictionary class a bit, not really what I am looking for.
-
Remove duplicate nodes from xml using c#I an having some trouble with removing duplicate entries from an xml file. I am using mostly Linq to XML and C# to build the list.So I would like a Linq to Xml aproach further too. Example(before): <SYNSET> <ID>new_id</ID> <SYNONYM> <LITERAL>word1<SENSE>II.♦</SENSE></LITERAL> </SYNONYM> <DEF> definition1 </DEF> </SYNSET> <SYNSET> <ID>new_id</ID> <SYNONYM> <LITERAL>word2<SENSE>I</SENSE></LITERAL> </SYNONYM> <DEF> definition2 </DEF> </SYNSET> <SYNSET> <ID>new_id</ID> <SYNONYM> <LITERAL>word1<SENSE>II.♦</SENSE></LITERAL> </SYNONYM> <DEF> definition1 </DEF> </SYNSET> After it should be: <SYNSET> <ID>new_id</ID> <SYNONYM> <LITERAL>word1<SENSE>II.♦</SENSE></LITERAL> </SYNONYM> <DEF> definition1 </DEF> </SYNSET> <SYNSET> <ID>new_id</ID> <SYNONYM> <LITERAL>word2<SENSE>I</SENSE></LITERAL> </SYNONYM> <DEF> definition2 </DEF> </SYNSET> The xml database should have around 100k entries like this, so I need a fast method to remove duplicates. Thanks in advance
-
Adding xml code to another xml file [modified]I do this:
XDocument xmlDoc = new XDocument();
if (indice == 1)
{
xmlDoc =
new XDocument(
new XDeclaration("1.0", Encoding.UTF8.HeaderName, String.Empty),
new XComment("Xml Document"),
new XElement("alinieri",
new XElement("align",
new XAttribute("id",indice),
new XElement("edtlr-def",entry_node[idx]),
new XElement("wnrom-synset", wn_synset)
)
)
);
xmlDoc.Save("alinieri.xml");
}my entry_node[idx] is a string containing xml code,same is wn_synset. My problem is that in the saved xml it shows this(just the beginning): <definition> <SpecDef>(Uneori cu determinări care indică sursa, provenienţa)</SpecDef> instead of (Uneori cu determinări care indică sursa, provenienţa) as it is in the one of the strings. And the & lt ; & gt ; were supposed to be < >. What should I do?
modified on Wednesday, March 11, 2009 4:08 AM
-
Getting substring from a lineYep I thought at that option too earlier and it works... I solved my problem with indexes and substrings. Thanks
-
Getting substring from a lineI use that namespace, but there is no mystring.Find - I just want to find the index of the first space in a line
-
Getting substring from a lineSo I read a file and that file has like 9k lines. the lines look like this(well it might not fit here, but is on a line only): A:"extatic" A:"extatici" A:"extaticul" A:"extaticului" A:"extaticii" A:"extaticilor" A:"extatică" A:"extatice" A:"extatica" A:"extaticei" A:"extaticele" A:"extaticelor" And I use textreader in c# to find a char in that text for example "extaticele" here. What I want is to extract if I found the char on that line the first char on that line. In this case "extatic" - but without "" of course and paste it in a text file. I dont know exactly how to work with find space so I want your help...cause I thought I'd find the first space in the line then take the index and with the index 0 of the line to extract "A:"extatic" ". Then remove the "A:" and the ". I saw somewhere an example with myString.find("") , but I can't find the "find" I might need a namespace.
-
C# launches another programrun.bat launches the java programs in .jar format(tnttolem.jar,towp.jar,txttoint.jar) - also run.bat uses a perl program too.
-
C# launches another programman...I already use this. string targetDir; targetDir = string.Format(@"E:\desk\baaaars\copy\copy\romm"); p = new Process(); p.StartInfo.WorkingDirectory = targetDir; p.StartInfo.FileName = "run.bat"; // p.StartInfo.Arguments = string.Format("C-Sharp Console application"); p.StartInfo.CreateNoWindow = false; p.Start(); p.WaitForExit(); read the content not just the title next time.
-
C# launches another programI have a program written in C# and from it I want to start another file ,some run.batch (which has a java program written behind) . Problem is that the 2nd program(a text processor) has an error when it is processing a text in 0:00:00 (no time) . But it works. I just have to click cancel debugging, so I can do my job further. 2nd program is closed source and cannot be modified. What I want to do is to catch the errors from my main program if possible. Thank you.