|
As Pete would tell you Dictionary<string, string> is an implementation of a Hashtable that is type-safe, and more efficient (in that no boxing/unboxing is done). Just change the Hashtable in the empData declaration to Dictionary<string, string> (both of them), and remove the .ToString() where you set hashData (it is unnecessary).
Other simple suggestions I'd make for this code:
* You ought to validate that the FieldCount is at least large enough for the number of fields expected, to detect a malformed CSV file.
* If there is any chance you'll need the individual fields later and have to "tear-apart" the concatenated string, I'd suggest creating a class to hold the individual fields as properties and storing that in the Dictionary instead. It can keep the concatenated string as a property, or concatenation can be used where necessary.
* empData.Add(userEIN, ...); will throw an exception if a userEIN value is not unique. You should handle that case, or change to empData[userEIN] = ...; if you just want to keep the last value encountered for the given userEIN .
* You shouldn't need the data array and the use of csv.CopyCurrentRecordTo(data) . Your code appears to be using the CsvReader of Fast CSV Reader of Sebastien Lorion[^]. If so, it has the ability to get the field values of the current record by the name found in the headers row. So, I'd suggest making constant strings for the expected header names and use the indexer to get the field values. E.g.:
const string FirstName = "First Name";
const string MiddleName = "Middle Name";
fName = csv[FirstName];
mName = csv[MiddleName];
This is much more readable and self-documenting.
* If you use the constants for the expected header names, you should verify that those headers are actually present in the file. You can use, e.g. csv.GetFieldIndex(FirstName) >= 0
* If you don't want to use the header names to lookup the field values, then you can still use named constants for the column index values, instead of the hard-coded column numbers you use now.
const int FirstName = 1;
const int MiddleName = 2;
fName = csv[FirstName];
mName = csv[MiddleName];
I hope this all helps.
|
|
|
|
|
Thank you so much for the detailed explanation. I will implement the suggestion you provided!!
|
|
|
|
|
is this possible to load unmanaged dll? When changing "target platform" to x86. It does work ok. But we prefer to keep it AnyCPU state.
We keep getting "BadImageException" error on this when using ANYCPU state.
|
|
|
|
|
As far as I know, you can't mix 32-bit and 64-bit in the same process. A 32-bit EXE can't load a 64-bit DLL, and vice-versa.
So if your unmanaged DLL is only available as 32-bit, you need to build your process as 32-bit (x86)... The "AnyCPU" setting is probably defaulting to 64-bit, because it doesn't detect any managed 32-bit assemblies in the project.
|
|
|
|
|
As Ian said, Windows only deals with homogeneous processes, so all the code must be 32-bit or all of it 64-bit.
A managed app targetting "AnyCPU" gets launched as 64-bit on a 64-bit OS, and will refuse to load 32-bit code.
If you have unmanaged dependencies, the practical way is NOT to use "AnyCPU" and therefore it is a pitty that
(1) it is the default, and (2) Visual Studio Express doesn't really give you direct access to any other setting.
|
|
|
|
|
I'm trying to understand what's going on... When I created the custom control and dynamic buttons, and run it on my pc. i see everything on my GUI. But when running on my co-worker's computer, the dynamic buttons aren't showing. These buttons are hard coded in their GUI location.
I apparently discovered that the buttons were hidden behind the custom control on my co-worker's computer.
The computer and gui size are as follows:
my computer (x86):
Screen resolution - 32-bit (true color) 1440x990
GUI size: 549, 352
my co-worker (x64):
Screen resolution - 32-bit (true color) 1920x1080
GUI size: 732, 433
What gives? I had believed that the GUI would be at the same size. Care anyone explain? My co-worker got my source code and her visual studio (same version as mine) and the custom control size has shown to be bigger size than mine.
modified 9-Jul-12 13:03pm.
|
|
|
|
|
What DPI are you both viewing at?
|
|
|
|
|
Ahh! That explains it! My pc is set to 100% (96 DPI) and she has 125% (120 DPI).
So that would mean I would need to make adjustment on my code to calculate DPI value.
Gonna find out how to do this!
|
|
|
|
|
Or not. If you use anchoring, you effectively remove the dependency on resolution.
|
|
|
|
|
Rather than recalculating the positions yourself, you may get satisfactory results by using the Anchor or Dock properties of your Controls; setting Form.AutoSize often helps too.
|
|
|
|
|
Hello!
Could anyone please help me with this:
XAML:
<ContentPresenter Content={Binding Path=Navigation}/>
ViewModel
private UserControl navigation;
public UserControl Navigation{
get {return navigation;}
set {navigation = value; OnPropertyChanged(()=>Navigation);}
}
void LoadControl(UserControl control)
{
this.Navigation = control;
}
What I want to do is create an animation which changes the Width of the ContentPresenter stepwise.
If control != null step from 0 => control.Width
else step from control.Width => 0
Any ideas how this can be done (can this be done in XAML soley)?
Help, as always, would be highly appreciated.
|
|
|
|
|
Hi,
I've faced some problem when am trying to return the LINQ class type function's result as a DataSet type.
If any one Know About this, Help me.
thanks in Advance!
|
|
|
|
|
I am trying to create an Excel line-column combination chart using C#. I know how to create a line chart or a column chart but I don't know how to create a combined chart. Could anyone please point me a direction or provide a short sample code on how to create such chart? Thanks in advance.
|
|
|
|
|
You can achieve this adding SecondaryAxis to the chart.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
Can you show me example code?
I have tried and got error.
myChart.Series("Series 2").XAxisType = AxisType.Secondary;
|
|
|
|
|
Which office version are you using?
Basically, you will have to create a new chart type and then add a series to it. You will then have to add this to your Chart.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
How to draw a excel chart with combination of bar and line charts.
eg: left handside is frequency, right handside is percentile with the interval as x-axis.
And how to remove the legend entry?
|
|
|
|
|
|
That is a surface chart.
What I want is a line graph + column graph on the same chart
|
|
|
|
|
I have an array includes list of users session id.
I wanna expire all of them.
Is it possible in ASP.Net (c#), if so, how ?
else, how can I do it with C#?
Thanks in advanced
|
|
|
|
|
Try Session.Abandon();
This should destroy data related to the session.
BTW, this is the C# forum.
Try posting in the ASP.Net forum next time onwards....you have better chances of getting a propert answer.
|
|
|
|
|
Well, Because I guess, it couldn't done in ASP.Net, I've written it in C# forum.
AFAIK Session.Abandon(); expire current session ! I wanna expire a session with session id
|
|
|
|
|
If I were doing this, I would use SessionIdManager[^] as a base. Basically, I would inherit from this and implement my own session management.
|
|
|
|
|
Hi, i am working on a project named object tracking in video files as part of my academics.
I used "A Simple C# Wrapper for the AviFile Library" for working with Avi Files.
It is working well in my system for my inputs and getting output as expected.
My system configuration
os: windows 7
.net version: Visual studio 2010(version 4)
And when i tried to run the same code on different system with same
configuration as mine it is not working.
and also i tried to do with different configuration as shown below.
os: windows XP Service pack 2
.net version: Visual studio 2008 (version 3.5)
it is also not working.
no errors.
no warnings.
I'm getting exception showing "process or thread has changed since last step"
exception at
" if(getFrameObject == 0){ throw new Exception("Exception in
VideoStreamGetFrameOpen!"); }" in VideoStream.cs file.
I'm not getting the solution what changes i've make to run the code on
other system.
|
|
|
|
|
Please restate your question more clearly. First you say "no errors, no warnings," then you say you're getting an exception.
Also, "it is not working" doesn't tell anything useful. Give details.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|