|
I am iterating in foreach loop, looking for some validation and then adding that to dttemp table;
foreach(Datatable dt in ds)
{
switch(dt.TableName)
{
case A:
foreach(DataRow dr in dt.Rows)
{
}
break;
.
.
.
case Z:
break;
}
}
Hope i make myself clear?
which is better way with reference to original post?
|
|
|
|
|
IMO, if you have just one datatable, the first approach is fine.
Why do you want to declare class level modules when you are using them only within a method.
My signature "sucks" today
|
|
|
|
|
Hum Dum wrote: Whats the diffrence?
Scope
Hum Dum wrote: and when to use which?
Use the second approach if the variables represent object-state, local variables and parameters if they don't. The hard part in that sentence would be defining "object state".
Let's take a Person class as an example. Now, if we introduce a variable for the age of the Person-object, then we're adding something that describes the state that the person is in. It contributes to the state of the object as a whole.
Next, if you want to iterate all arms that a person has, than you'd use a variable as a counter. That would be a local variable. If that variable were to be used to denote the amount of arms implemented, it would become a property.
I are Troll
|
|
|
|
|
Probably neither. But have separate classes (layers) to perform specific tasks -- perhaps the checkValue method should be in the Data Access Layer and the CallingFunction should be in the API layer.
checkValue should probably be defuined as bool checkValue(string msg, DataTable dttemp)
|
|
|
|
|
Here is an itemized list of reasons why:
1) Try to avoid using reference parameters. While they have a purpose they are difficult to maintain across developer experience levels and expectations.
2) Try to avoid using members as global variables. You introduce a lot of state into your objects that can be difficult to manage.
3) checkValue is misspelled. No matter which naming convention you use BE CONSISTENT! Your method should have been named CheckValue and yes it is an important distinction since checkValue tells experienced c# developers they are looking for a local variable.
4) CheckValue is a poor method name. Methods must be aptly named or chaos will ensue.
5) Your two samples actually have different results! See if you can find it.
6) Never use implicit scope.
7) I would provide a good example of how to do what you are asking, however, you code offers no clue as to the intent so the purpose of the question cannot even be inferred. However, I would suggest:
private DataRow CreateNewRow(DataTable table);
private bool IsDataRowValid(DataRow row);
private DataTable LoadDataTable();
private string CalculateSomeImportantDataFromRow(DataRow row);
Although, I personally would be using classes to represent my data instead of DataTables or Strongly typed data tables so my above suggestions do not take into account the "best" approach. Also, keep in mind, other than the CreateNewRow method no other method I described would have any side effects.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: 2) Try to avoid using members as global variables. You introduce a lot of state into your objects that can be difficult to manage.
If by lot state to object you means when someone create a object of class A, then these object got attached by that. But they are private(default access specifier, if nothing mentioned). So how?
Ennis Ray Lynch, Jr. wrote: 3) checkValue is misspelled. No matter which naming convention you use BE CONSISTENT! Your method should have been named CheckValue and yes it is an important distinction since checkValue tells experienced c# developers they are looking for a local variable.
where it is misspelled? (may be, as typed it here not on VS)
I use camel casing, Why it named as CheckValue, if you explain( does you mean variable should start with small letter then Capital, and method will always be Caps. but i read it somewhere you use Capital Naming if that method is Public).
Ennis Ray Lynch, Jr. wrote: 5) Your two samples actually have different results! See if you can find it.
How tell me.
Ennis Ray Lynch, Jr. wrote: 6) Never use implicit scope.
By that you mean inside method or what?
Ennis Ray Lynch, Jr. wrote: I would provide a good example of how to do what you are asking
Let me explain?
I am picking an xml file from a folder, loading that in to DataSet object, iterarting its DataRow, doing some validation on XML nodes(Datarow), after validating them filling them in DataTable, applying sorting on this temp dataTable. and then genrating a text file.
|
|
|
|
|
Simplest code for your given problem: ( I just typed quickly and left stubs but it should give you an idea of a simple approach that is readable)
public static class Foo{
private static DataTable GetDataTableFromFile(string filePath);
private static bool IsRowValid(DataRow dataRow);
private static void WriteRowToStream(Stream stream);
public static void OutputXmlFileToTextFileOrSomeOtherJunk(string inputFilePath, string outputFilePath){
DataTable data = GetDataTableFromFile(inputFilePath)
using(FileStream stream = new FileStream(outpuFilePath, FileMode.Create, FileAccess.ReadWrite)){
foreach(DataRow row in data.Rows){
if(IsRowValid(row)){
WriteRowToStream(row);
}
}
}
}
}
|
|
|
|
|
hi friends
i have a c++ dll which contains function and class.
c++ dll code
class __declspec(dllexport) MyClass
{
public:
MyClass(void);
~MyClass(void);
void GetName()
{
.......
}
};
_declspec(dllexport) void MyFun()
{
}
My c# code follows
public partial class Form1 : Form
{
[DllImport("CPPDLL.dll", EntryPoint="MyFun")]
static extern void MyFun();
[DllImport("CPPDLL.dll", EntryPoint="MyClass")]
static class MyClass;
public Form1()
{
InitializeComponent();
}
}
but DllImport for class(MyClass) shows syntax error.
how can i solve this problem
thanks in advance
-kk.tvm-
|
|
|
|
|
DllImport doesn't work with classes. You can't import a class - if you need the class structure, it's up to you to redefine it as a struct at the C# side.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Pete O'Hanlon
Redefine ?
-kk.tvm-
|
|
|
|
|
It means you need to code up the C# equivalent.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi every one..
Is there any library or dll or any other tool for FREE to create or use skin for window forms.Please tell tool other than uskin,krypton toolkit.
and wpf concept.
thanks in adv..
|
|
|
|
|
There is a Component for skins, but it's a comercial product, but it's not expensive
The Name is "IrisSkin" from sunisoft, it's a really good component for use own skins.
Hope i could help you a bit.
|
|
|
|
|
But it is not for free. Is there any tool like that for free. I searchd on google but unable to find that.
|
|
|
|
|
I used to use IrisSkin, but the last time I tried, I ran into some problems. When using it in VS 2008, it turned out that the components flicker.
I notified Sunisoft, they said that they were able to reproduce the problem, but they never came back with a solution.
I haven't used the component since then, and I'm a little p'd off that they don't fix the problem seeing that I paid good money for the component.
|
|
|
|
|
I never had problem with flickering, i'm using it in VS 2008 too... the component works without any cause.
Did you check for updates? Maybe the developer have fixed the problem in a newer version of IrisSkin but haven't given feedback to you.
Which way the components flickers? Is it flickering everytime or only on certain Layout events?
|
|
|
|
|
I didn't really remember, but I went back and had a look at my email to Sunisoft.
Seems that the skinned components (groupboxes, comboboxes, textboxes and labels) flickers when you move the mouse over them, the form itself is ok, no problem there.
I must be using the newest version, because my bug report was made after the release date of the latest version (as per Sunisofts site). Needless to say, i always update my components before filing a bug report to make sure the problem hasn't been fixed already.
|
|
|
|
|
I use IrisSkin and Krypton in combination.
Krypton isn't suitable for a custom Form Skin, because the visual effects of the OS are need to enabled. So i have found IrisSkin to Skin a Form without visual effects.
I notified sunisoft that i wan't to modify the using Skin at runtime because i have created a class for handle the colors of Krypton and IrisSkin, so i can create Palettes with der PaletteDesigner from Krypton, the Palette will assumed to the Skin for the component automatically by the class at runtime. With a update from sunisoft it has been complete possible, so i have decided to buy this component and i'm content with this decision.
I never tried to skin Controls with the component, but there have been alot of updates from sunisoft.
Hope i could give some ideas.
|
|
|
|
|
You have asked the same question many, many times and been given the same answers many, many times. Doesn't that tell you something? If people aren't giving you links to free code, it probably means there isn't any.
BTW - you should have asked this in the Windows Forms forum - this is not a C# issue.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
1 thing I want to ask u, have u given any suggestion related to query..
R u getting what I want to ask or it may be possibilty there may be free tool but U are not aware of it.
So please if u don know , please DO NOT DISTURB.
|
|
|
|
|
jainiraj wrote: please DO NOT DISTURB
I understand perfectly what you are after. I also know that people have repeatedly pointed you towards none-free tools, but you insist on coming back here and asking the same question. If nobody has pointed you towards free tooling, this should be a strong indication to you that you are going to have to pay or write it yourself. There are articles here on CP on how to achieve some of this, but it is going to require you to actually write some code.
So, stop being such a rude idiot and actually apply some thought to this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
jainiraj wrote: please DO NOT DISTURB
So instead of taking the suggestions presented to you, you act like this? A simple google search will give you what you want but given your rudeness I am not sure that I want to suggest that to you.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
jainiraj wrote: 1 thing I want to ask u, have u given any suggestion related to query..
R u getting what I want to ask or it may be possibilty there may be free tool but U are not aware of it.
So please if u don know , please DO NOT DISTURB.
LMAO!
Please excuse the semi Off Topic
[on soapbox]
From your profile, it says you're in the USA and have been on the board for just over a year. Let me guess, you're a clueless student? Maybe even in High School or Grade School?
One thing is very clear, you don't have a CLUE about software, engineering, computers, or getting help.
Honestly, how foolish does someone have to be to know that they suck at spelling, but they still ask forums questions without using the FREE and very available Firefox and IE spell checkers?
Yea, I see it all the time in the car forums. But, it's mainly from newbies and 16->18 year olds.
IMHO, if someone isn't smart enough to know that their spelling sucks and to learn how to use the very simple Firefox or IE spell checkers, then there is NO WAY IN **** they should be coding!
[off soapbox]
_______________________
Joe
|
|
|
|
|
It is posible to storing path of appData folder in app.config file.
Now i have:
string folderConfig = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
But I want to have this same in app.config.
In log4net is something like this:
< f i l e value="${APPDATA}\log-file.txt" />
but it doesn't work correct, it create folder called ${APPDATA} instead of creating file in appdata folder,
or I don't know how to read this section properly.
modified on Wednesday, June 16, 2010 4:39 AM
|
|
|
|