|
Ah, I was just deriving from context... So he's got more bugs buried underneath the bugs he's spotted
|
|
|
|
|
don't worry, the compiler will spot them. And we will be informed, no doubt.
|
|
|
|
|
Perhaps you could wrap your code in a PRE block and paste the exact error messages you are getting and indicate which line they are occurring on? Here's an example of how to use a PRE block:
<pre lang="C#">List<int> x = new List<int> {1, 2, 3};</pre>
Here's what that looks like:
List<int> x = new List<int> {1, 2, 3};
You can edit your original message to make that change.
|
|
|
|
|
|
I finally figured it out, this works as intended:
//Open files into the list box
private void btnLoad_Click(object sender, RoutedEventArgs e)
{
//Declare an instance of the open file dialog...
OpenFileDialog dlg = new OpenFileDialog();
//Set properties for the dialog...
dlg.Title = "Select one or more media files";
dlg.Multiselect = IsEnabled;
dlg.Filter = "Media files(*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv)|*.mp3;*.wav;*.wma;*.avi;*.mp4;*.mpg;*.wmv|All files(*.*)|*.*";
//The result of the open file dialog is either true or false (didn't work).
Nullable<bool> result = dlg.ShowDialog();
//If the result of the open file dialog was true then....
if (result == true)
{
string[] files;
files = dlg.FileNames;
foreach (string file in files)
{
lstBxList.Items.Add(file);
}
}
}
|
|
|
|
|
yes, that looks better, except that you are still not using PRE tags to show a code snippet.
|
|
|
|
|
Hi,
I have some queue that i fill with some chars.
The queue is filled all the time ( add char each 10 milliseconds )
When the queue have 20 chars ( or more ) i need to type the chars on the text line.
I try to update the text line from other thread but i get some strange exception ( "external exception e0434352" )
The code:
<br />
public delegate void UpdateTextCallback( Char ch ); <br />
<br />
private void addToQueue( object sender, char ch )<br />
{<br />
lock( locker )<br />
{<br />
IncomingCharQueue.push( ch );<br />
<br />
if( IncomingCharQueue.Count > 20)<br />
{<br />
textBox.Invoke( new UpdateTextCallback( UpdateText ), IncomingCharQueue.Dequeue() );<br />
<br />
}<br />
}<br />
}<br />
<br />
private void UpdateText ( Char ch )<br />
{<br />
textBox.Text = Ch;<br />
}<br />
<br />
|
|
|
|
|
First, make sure to check if invoke is required (using this.InvokeRequired ) before you perform an invoke. Next, try using "this.Invoke" rather than "textBox.Invoke". Not sure if any of that is your problem, but it's worth a try. Also, read this tip/trick for easier ways to invoke.
|
|
|
|
|
A queue is probably the wrong structure. Give or take syntax errors. Wrote this for .NET 2.0 so it is relevant for most flavors.
StringBuilder sb = new StringBuilder();
private void Add(char a){
lock(this){
sb.Append(a);
if(sb.Length >= 20){
UpdateText(sb.ToString());
sb.Length = 0;
}
}
}
private void UpdateText(string abc){
if(InvokeRequired){
Invoke(delegate(){
textBox.Text = abc;
});
}
else{
textBox.Text = abc;
}
}
|
|
|
|
|
But in case that the add method is call evry 5 milisecond - i have this exception again.
The exception is appear in the line that the text is sign up to the control.
Someone can help with this ?
Thanks
|
|
|
|
|
please answer with sample... i googled but i mixed up!
|
|
|
|
|
I'm not sure what this has to do with C#, but this[^] may be what you are looking for.
It's time for a new signature.
|
|
|
|
|
i meaned condition compilation symbols! there is no info about condition compilation symbols in that link
|
|
|
|
|
mersad00 wrote: there is no info about condition compilation symbols in that link
I have not used this myself but looking at the documentation I am of the opinion that you cannot add conditionals; it is assumed that they are already set in the project that is to be built.
It's time for a new signature.
|
|
|
|
|
Hi,
How i need to write this query with linq-
<br />
SELECT Id<br />
From Persons<br />
WHERE FirstName IN ('Name1', 'Name2', 'Name3')<br />
i don't know how to translate the IN statment.
Can someone please help me?
|
|
|
|
|
As far as I know: you can't. That's a limitation of LINQ.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
Make an in memory collection of your list and then join it in LINQ.
That said, LINQ sucks, use SQL.
|
|
|
|
|
Can you please explain?
|
|
|
|
|
"IN" isn't any better in SQL. There's no easy way to implement IN clause in .NET when interacting with database.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: That said, LINQ sucks, use SQL.
I've always wanted to here another developer say that! In fact, I would love for codeproject to do a survey on how many developers even use LINQ.
The mind is like a parachute. It doesn’t work unless it’s open.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: That said, LINQ sucks, use SQL.
LINQ to SQL yes kind of sucks for me too.
But LINQ to objects(lists, collections etc) rocks and also LINQ to XML rocks.
At least for me.
I bug
|
|
|
|
|
In general you should never have a list in memory large enough for LINQ to be beneficial. And specifically, for the cases where you should, a specialized data structure is more appropriate. LINQ only solves one problem and that problem is how to sell MS licenses to companies.
That being said, I am guilty of using LINQ on rare occasions.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: In general you should never have a list in memory large enough for LINQ to be beneficial
Yeah I know that. You're right(not left).
But even on a smaller list I very much prefer:
var something = from rec in datas
where rec.SomeProp >= SomeValue
select new { Name = rec.Name, Amount = rec.Amont;}
than creating a new type/class for that incomplete data type and then manually yielding/foreachingMDL
I'm not happy with anything slower than a BinarySearch so I too create
very specialized data/object model(s).
But for add on's or temporary stuff I prefer Linq over manual creation.
I bug
modified on Thursday, August 12, 2010 6:37 PM
|
|
|
|
|
Write your own extension method, if it's that important to ya...
public static bool IsIn(this object obj, params object[] args)
{
foreach (object a in args)
if (obj == a) return true;
return false;
}
Or something like that.
|
|
|
|
|
Hi,
Look up "Contains" for a linq statement. That inserts an "IN" statement for SQL.
|
|
|
|