|
Hi Estys,
Thanks for the reply. Yeah, I need to pass a list. Can't help it!
Actually the ChildEntity is just one example. The BaseEntity is a base class for May child entities, say, ChildEntity1, ChildEntity2, ChildEntity3, etc.
Thus, the list could be of any of these types and certain convert actions need to be taken on the same.
Your solution seems to be great, but aint it a bit complicated. Is there a simpler one?
Thanks and Regards
-
Sameer
|
|
|
|
|
This works :
static void Conv (BaseEntity baseEntity)
{
baseEntity.id = "b";
}
Invoke like this :
listChild.ForEach(Conv);
It doesn't use a list. Your problem with List<T> is that it won't cast to another type.
|
|
|
|
|
Hi,
We are using Crystal reports 11 (developer version) in our product. I would like to know, how can we handle the localization stuff in crystal reports other than using the third party tools (like "Crystal Translator"
Our application is developed in C# . Here for localization stuff in C#is very simple and we can place all strings in .resx, then the translation is required for only the .rc file according to the language.
Is there any similar functionality/feature is there crystal reports 11 to support for the localization stuff ?.
If you guys through some light on this, it will be very helpful to me.
Thanks
|
|
|
|
|
I have a XML file (foo.xml)that contains about 100 tags. One of the tags looks like this:
"<"CONNECTION HOST ="XYZ"/>
NOTE-no quotation marks before or after the starting less-than sign
Any body has an example on how to extract the XYZ data using C#?
your help is greatly appreciatedmodified on Monday, March 1, 2010 12:22 AM
|
|
|
|
|
That is NOT a well formed XML file, you cannot expect XML to work on crap data, you will need to parse this manually, just like any other text file.
You could read it in and to a replace on "<", then use the xml parser!Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It is well-formatted, it just does not display correctly if I type it the correct way and hence the NOTE-no quotation marks before or after the starting less-than sign
basically it is
OPEN bracket-CONNECTION HOST ="XYZ"/ - close bracket
|
|
|
|
|
We can't see your tag: Try checking this before pasting your XML: Encode "<" (and other HTML) characters when pasting
edit: Damm, my browser cache.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<CONNECTION HOST =\"XYZ\"/>");
XmlElement xml = doc.DocumentElement;
MessageBox.Show("Atribute name: " + xml.Attributes[0].Name + "\r\n Atribute Value: " + xml.Attributes[0].Value);
|
|
|
|
|
Hi,
I'm a newbie and need some help.
How do I go about saving a variable using c# code.
|
|
|
|
|
It depends on the type of the variable and what you mean by 'saving'... to a file, a database, in memory, sharing with another class etc...
|
|
|
|
|
Thanks alot for the reply.
I need to save the variable temporarily for use later.
Thanks in advance for any help you can provide...
|
|
|
|
|
|
I would say hours at the most
|
|
|
|
|
Look into variable SCOPE, assuming you are not talking about saving the value past the end of the current session (stopping the application) a variable is available until it runs out of SCOPE. Do NOT fall into the VB trap of making all your variables global or static. Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi!
I have a problem. I have created a time sheet system that enables a person to enter a start time and an end time. It then calculates the total hours worked.
The problem I have is this:
When a person has been on lunch from say 11:00 to 11:30 and then wants to enter a time worked say 11:15 then an exception should be thrown stating that times cannot overlap. How will I go about checking for this?
Thanks in advance!!Illegal Operation
|
|
|
|
|
two intervals [b1,e1] and [b2,e2] overlap when any of the following is true:
b1<=b2<=e1
b1<=e2<=e1
b2<=b1<=e2
b2<=e1<=e2
So start comparing begin and end DateTimes.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
modified on Sunday, February 28, 2010 8:15 PM
|
|
|
|
|
If you google for c# DateRange you will find a number of classes that people have written to address this sort of problem, i.e. dealing with fixed periods of time and testing for intersection with other periods, and so on. One example is here:
http://noticeablydifferent.com/CodeSamples/DateRange.aspx[^]
This example is OK, except I would make it immutable since in its present form it's not thread-safe.
|
|
|
|
|
Hi,
I'm trying to move a file from 1 directory to another.
But no matter what I try, I keep getting this error at runtime:
Cannot create a file when that file already exists.
string[] filePaths = Directory.GetFiles(dir1, "*.txt");
Directory.Move(filePaths[i], checkedFiles);
All the files in filePaths are in bin\debug\FilesToCheck folder
And checkedFiles folder is in bin\debug\checkedFiles
What am I doing wrong?
|
|
|
|
|
Make sure checkedFiles ends on a backslash, making it a folder, not a file.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
It has an ending backslash. The file is made with Path.Combine()
And in there i added the ending slash.
|
|
|
|
|
Please show us the first and last of the filePaths[] elements, and the checkedFiles value, as seen by your app.
Why do you use Directory.Move rather than File.Move ?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I tried them both. And both give me the same error at runtime.
Here are the 2 elements in the filePaths[]:
[0]"C:\\Users\\The User\\Documents\\Visual Studio 2008\\Projects\\ProjectMultiThread\\ProjectMultiThread\\bin\\Debug\\filesToCheck\\634029044974663752.txt"
[505]"C:\\Users\\The User\\Documents\\Visual Studio 2008\\Projects\\ProjectMultiThread\\ProjectMultiThread\\bin\\Debug\\filesToCheck\\634029930615165770.txt"
The checkedFiles variable:
C:\Users\The User\Documents\Visual Studio 2008\Projects\ProjectMultiThread\ProjectMultiThread\bin\Debug\Checked Files\
I tried the 'checked files' with and without a space.
Just for the record, I'm trying to move this file from folder filesToCheck: '634029930615165770.txt'
To the 'Checked Files' folder.
I have used File.Move and:
FileInfo fi = new FileInfo(this.filesToCheck);modified on Monday, March 1, 2010 5:28 AM
|
|
|
|
|
Luc Pattyn,
I fixed the problem. I found this site:
http://www.devnewsgroups.net/dotnetframework/t1557-file-move-file-copy-exception.aspx[^]
And: Jacky Kwok's reply to someone else's post did the trick.
But I don't quite understood what he said. A quote from what I mean:
[quote]
The "BackUpPath" in both "Copy" and "Move" in your code are directory only.
However, the "File.Copy" and "File.Move" require it is filename.
[/quote]
If I understand this correctly, File.Move wants in both arguments a File name like this:
File.Move(file1, file2);
Isn't that odd? I'm trying to move a file from one directory to another. But here, you're moving a file to another file?
|
|
|
|
|
Yes, File.Move takes two filenames, that is perfectly clear in the documentation.
FYI: when both files reside in the same disk partition, the file data is not copied, the file is just renamed, i.e. one or two folder lists get modified.
The documentation on Directory.Move is not very clear however; AFAIK it can move an entire folder (when given two folder names), or it moves a single file (when given two file names).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
So you're saying i have to pass the same file name to the destination argument too?
|
|
|
|
|
Hi Luc,
It seems that the files which are moved, are somehow messed up.
- If i try to open it, it's empty and ms windows is 'asking' me if i want to create a new file.
- If i try to delete the file, windows is 'telling' me that the file "is no longer located in the-file-path".
I was hoping you could help me out here.
|
|
|
|