|
raju_shiva wrote: I tried the same ,but stilll the same error
Why don't you try something like following?
HashSet<string> hashSet = new HashSet<string>();
hashSet.Add("abc");
hashSet.Add("aa");
Knock out 't' from can't, you can if you think you can.
modified on Monday, July 5, 2010 2:45 PM
|
|
|
|
|
<pre>Dictionary<string,string> m_mapId = new Dictionary<string,string>();
Dictionary<string,string>.Enumerator it = m_mapId.GetEnumerator();</pre>
However, it's unusual to deal with enumerators directly in C# - instead just use a 'foreach' loop, which enumerates for you.
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
-- Modified Wednesday, June 30, 2010 5:36 PM
|
|
|
|
|
David Anton wrote: However, it's unusual to deal with enumerators directly in C# - instead just use a 'foreach' loop, which enumerates for you.
Any example that lets unusual deal of C# enumerators?
Knock out 't' from can't, you can if you think you can.
|
|
|
|
|
A breif outline of what I need to is generated a Word Document (2003 format) by appending a series on single (A5) Word Document templates files.
1. Load the Word template
2. Do a number of search/replace operation (driven by data from another file)
3. Insert at the end of the previous document
4. repeat till last file.
Using word interop is dreadfully slow this and takes at least an hour for 20 pages. So I am considering converting the templates to XML and using OpenXML to do the above. The search/replace could then even be done by treating the XML file in plain text format.
What I can't find is info on how I can then insert one XML file at a bookmark in the previous and of course still have a valid Word XML doco at the finish.
Someone must have done something like this before.
Thanking you in advance.
Happy programming!!
|
|
|
|
|
hello,how are you?
please i need you to help me because i'm new programmer in c#.
if don't mind,i do my code in c++ last year but now i need the same code
in my new program by c# but i'm not very good in c# and i don't know how to do it
so can you help me please because it's really important for my program.
thank you for your cooperation
nice to meet you
|
|
|
|
|
Hello, I'm fine - thanks for asking!
I'm glad to hear you are learning something new; it is always worth doing.
We will help if we can, be sure of it.
You are more than welcome - come again soon!
What a nice chap (or chappette) - isn't it a refreshing change to have a polite, pleasant enquiry here?
PS: There is only one detail you forgot, old chap: What was your question?
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Thank you for your cooperation and i really apprecite your help
tomorrow i'll send you the file of the code
nice to meet you
|
|
|
|
|
No, don't email it to me: post what you are having difficulties with as a question.
If you email it to me, no one else can see, or help, and some of them may have more or better knowledge of your exact area than I do.
Start a new question, and describe your problem. Include short code fragments, using the "code block" widget to preserve formatting - don't just post a whole C++ file and say "I need this in c#" because you will get a lot of abuse from various people if you do! Read the bit at the top of the page, where it says "How to get an answer to your question" before you post it.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Why I can't smell the sense of c++ programmer in you ?
I know nothing , I know nothing ...
|
|
|
|
|
I transfered from C++ to C#
Please say what help you need.
|
|
|
|
|
hello ,
Am tring to use Excel SpreadSheet on the Windows form. The datasource is a datatable. While am giving the datasource as Datatable it is not working . It is asking for MSDATASRC. Any one knows how to convert Data Table to MSDATASRC..
|
|
|
|
|
These are some C# class members:
[StructLayout(LayoutKind.Sequential)]
unsafe struct MyStruct
{
public int size;
public byte* data;
}
[DllImport("MyStruct.dll", CharSet = CharSet.Unicode)]
static extern unsafe void MyFunction(MyStruct* myStructs, unsigned int nMyStructs);
How to create such array of MyStruct in C# as in C to pass it to MyFunction from C#?
unsigned int N = 10;
MyStruct* pMyStructs = (MyStruct*)malloc(N * sizeof(MyStruct));
MyFunction(pMyStructs, N);
Чесноков
|
|
|
|
|
you need to rewrite the MyStruct in C# using the MarshalAs attribute at the vars declaration.
something like above its only a example ^^
you need to take a look at the mapping of your C byte* to C#..
<br />
[StructLayout(LayoutKind.Sequential)]<br />
unsafe struct MyCSharpStruct<br />
{<br />
public int size;<br />
public IntPtr data;<br />
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]<br />
public string MyString;
}<br />
<br />
[DllImport("MyStruct.dll")]<br />
static extern void MyFunction(ref MyCSharpStruct myStructs, unsigned int nMyStructs);<br />
|
|
|
|
|
You can allocate the memory whereever you want. A simple solution might be to allocate it in managed memory as .NET array:
MyStruct[] myStructs = new MyStruct[N];
fixed (MyStruct* pMyStructs = myStructs) {
MyFunction(pMyStructs, N);
}
In this case, the GC will take care of freeing the memory.
You can also allocate on the stack (if N is small, for large N you would risk a stack overflow):
MyStruct* pMyStructs = stackalloc MyStruct[N];
MyFunction(pMyStructs, N);
In this case, the memory is freed immediately when leaving the function that allocated it.
If you want to allocate in the unmanaged heap, then use one of the allocation functions in the Marshal class:
IntPtr memory = Marshal.AllocHGlobal(N * sizeof(MyStruct));
try {
MyStruct* pMyStructs = (MyStruct*)memory.ToPointer();
MyFunction(pMyStructs, N);
} finally {
Marshal.FreeHGlobal(memory);
}
You could use Marshal.Copy to copy data from a managed array to an unmanaged pointer - but if you already have a managed array, you can simply use the first approach (fixed statement) to pass that without having to copy anything.
|
|
|
|
|
hi there,
Could anyone please give me a simple example of bluetooth transfer with c#?
i have googled that but no useful results.
my devices which i want to have the transfer are a hand held computer with windows mobile and the common PC with win xp or 7.
|
|
|
|
|
You can use 32feet.net or brecham obex fro transferring files to bluetooth device.
|
|
|
|
|
how to create picture boxes dynamically and display the pictures from sql server 2005.
pls help me.
thanks............
vamsi
|
|
|
|
|
You might want to take a look here[^].
|
|
|
|
|
You know how some website login forms change the color of textboxes you left empty to red?
I want to do that in my application.
Basically after entering data you can click a "check" button that is supposed to highlight empty textboxes in red.
I tried using a graphics object and draw rectangles above the textboxes, but it doesn't work well. Not the entire border is highlighted, but only the right and lower side.
|
|
|
|
|
Well,
I haven't done that but I must ask, why not use an error provider?
Just find the Error Provider[^] in your toolbox and drop one on your form.
Then you can use something like this to set the error when they click 'check'.
myErrorProvider.SetError(myTextBox, "Not Valid");
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
|
Another possibility is to place an asterisk (* ) in the text or color the boxes when the form is populated. Then in the Validating event, change the color, etc. if the result is valid. The color can be changed by setting the BackColor property, but you may need to refresh or Invalidate() the control to see the change.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
if it is a website, I would do this in client side code instead of server code. (saves a round trip to the server)
Add a validation function that is called on the onchange event for that control that will do some basic checking (empty fields, phone number formatting, etc...) and color the control accordingly. Alternatively you can skip the onchange event and put the validation when the form is submitted.
V.
|
|
|
|
|
It's not a website, it's a windows forms app.
I'm currently changing the backcolor to red and forecolor to white (when you change the text, the color also changes back to normal) but that looks kinda awkward.
If possible I'd like to use the more elegant way of just coloring the frame of the textbox/drawing a frame around it.
How does the blinking look? It's quite possible that there'd be like 5 textboxes on a form which require input and all of them blinking at the same time would probably weird and confusing.
I want a simple, yet obvious visual hint that there is something wrong.
|
|
|
|
|
Then use the ErrorProvider, just run some tests.
The ErrorProvider, see my previous reply, is a windows forms control so i dont really understand the
Megidolaon wrote: It's not a website, it's a windows forms app.
comment
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|