|
Thank you so much for the answer, that worked with minor change:
emailMessage.EmailParamHeaders.To.ToArray().ToList().ForEach(x => { if (x != null) m.To.Add(x); });
|
|
|
|
|
Why are you converting to array, and then to a list? Also, if your email message supports AddRange , an alternative is to try the following?
var addresses = (from p in emailMessage.EmailParamHeaders.To
where p != null
select p).ToList();
if (addresses != null && addresses.Count>0)
m.To.AddRange(addresses); Depending what's going on inside the Add method, you can often find that an AddRange works more efficiently.
|
|
|
|
|
In a C#.net 2010 application, I would like a suggestion on how to complete the following task:
In a string field, I need to make certain the only values that are returned by a routine are:
1. alphabetic characters only,
2. The result must be in uppper case,
3. No other characters are allowed.
Can you tell me how to accomplish this task?
|
|
|
|
|
Check your results for validty before you return the value from the method??
You can look into using Code Contracts[^] to simplify this process a bit.
|
|
|
|
|
I'd go with a Regex:
string input = "1234asdfASDFG,../;[][";
string output = Regex.Replace(input, "[^A-Z]", "");
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I want to place design surface on button control, which is located on design surface. Is there a way to place design surface inside other design surface?
I create new design control(design surface with button control as root component) in CreateInstance() of other design surface and have next exception:
The CurrentContext property of the LicenseManageris currently lockedand cannot be changed.
I think, during executing of CreateInstance()(of main design surface) current design host(of main design surface) is locked, therefore I can't create other design surface.
modified 12-Jun-12 3:54am.
|
|
|
|
|
Hi All,
I am writing an application and need to save some data with an incremental number.
My first thought was to use an integer that be could incremented and shoved out disk, now I am trying to do thing properly so I have come up with the following
String Path = Directory.GetCurrentDirectory();
string[] file_text = Directory.GetFiles(@Path, "*.txt");
string Name;
int FileTotal = 0;
for (int i = 0; i <= file_text.Length - 1; i++)
{
Name = file_text[i].Substring(Path.Length+1);
FileTotal++;
}
MessageBox.Show(FileTotal.ToString());
FileTotal++;
MessageBox.Show("Next File to Written is " + FileTotal.ToString());
It looks for the file (in the bit of example code .txt ...) adds one to the total for the next one. Is this the 'correct' way of doing things or am I creating a kludge that will come back and bite me later.
Glenn
|
|
|
|
|
What you are trying to do is unclear; please explain more clearly.
glennPattonWork wrote: Is this the 'correct' way of doing things or am I creating a kludge that will
come back and bite me later.
It might be OK, but I can't say for sure until I know what you are trying to accomplish.
Is there a database involved?
|
|
|
|
|
Hi,
Sorry about that I had not really had chance to proof read it when it got posted (mix of Web connection and finger trouble) What I am aiming to do is to create a load data files
such as Data001.msg, Data002.msg etc at the moment I have it updating a variable that goes to an ini file (I know, I am under orders to make an .ini, you bring up XML but no! separate story)I want the program to look at the location say there are six file with an .msg extension I would like the variable to be seven and create Data007.msg and on. I was trying to find a way to do this that wasn't too bad. Sorry, there is no database involved at this stage!
Glenn
|
|
|
|
|
glennPattonWork wrote: say there are six file ... I would like the variable to be seven
Well, then what about int FileTotal = file_text.Length ; ?
|
|
|
|
|
Thanks for that, I still wonder if I would better suited to something other than Windows programming!
|
|
|
|
|
|
Hmmm, LINQ never messed with it, I have a look....
|
|
|
|
|
|
Thanks for that when I have the time I will take a look at using LINQ, PIEBALDconsult's method works for what I am trying to do, can you recommend any sources for LINQ ?
|
|
|
|
|
|
I had found the MSDN stuff, so it looks like I have been LINQ'ing for a time with out realizing it....
|
|
|
|
|
|
|
There are obviously fairly serious synchronisation issues here, if there is any chance you could have two threads or two applications running at the same time. You probably realise that but just making sure!
|
|
|
|
|
As far as I am aware at the moment I have only one thread on the go! Thanks for the heads up though!
|
|
|
|
|
is it possible to make ping to another computer in windows-mobile
using C# code ?
thanks
|
|
|
|
|
Please don't crosspost. Pick one forum and stick with it.
|
|
|
|
|
I m new in this C# language so i find problem in talking sound input from mic.
I don't know how to use API and want to solve this problem without using API
|
|
|
|
|