Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
AnswerRe: C# linq issuementorDaveyM6930 Sep '12 - 22:54 
FirstOrDefault is your clue. If not found, it will return the default value for DateTime which is DateTime.MinValue.
 
Use:
if (complete_date != DateTime.MinValue)
Or
if (complete_date != default(DateTime))
instead.
 
null is default for reference types such as classes and interfaces, for value types such as structs there is normally a static readonly field or property available such as MinValue or Empty, or you can use the parameterless constructor to get the default, or default(...) as above.
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



AnswerRe: C# linq issuememberJohn Brett2 Oct '12 - 6:14 
DateTime is a ValueKind, so comparing it with null isn't very useful (it'll always not be null).
If your LINQ query doesn't find any rows, then FirstOrDefault() will return a default instance of the requested data type (DateTime, in this case).
There's a clue in the name Wink | ;)
If you want to know if you found any rows or not, either test the query first (e.g. Any()) before evaluating First(), or compare the returned value with the default DateTime value (DateTime.MinValue, IIRC). If you do that however, you won't be able to tell the difference between no rows, and rows where the first had the minimum datetime value.
QuestionHow to store string queries in c# functionmembernitin_ion30 Sep '12 - 17:52 
I am using string queries
SELECT CASE WHEN COALESCE(title2, title)='RUNTIME PARAMETER'
in function.
It is ok but I want them not to be written in the function because anyone developer can mess it up. There will be lot of queries which will get run time parameters also from functions.
 
I want it somewhere so that it is safe. But it should be available during run time, means if i want to replace a query the i should be able to so that without the need of building and deploying the files.
 
One way i was thinking is to use either resource files or config files but i cannot make mind. I don't want the performance to take a hit yet to maintain flexibility and maintainability.
 
Using resource files means to load read text which will incur some performance loss but is better than config files as they are not safe and easily readable.
 
Any suggestion?
AnswerRe: How to store string queries in c# functionprotectorPete O'Hanlon30 Sep '12 - 19:33 
Well, the performance hit of a resource file is negligible so I would go that way if I were you.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

QuestionC# 2008 update sql server tablememberdcof30 Sep '12 - 14:19 
I have a question about a C# 2008 application that calls C# 2008 application by using 'Process exec_calc = new Process();'. Curretnly the first C# 2008 application creates output excel spreadsheets that are emailed out to customers.
 
Now the first C# application will count the number of rows that are generated on the excel spreadsheet. The first program will insert a new row into a customer table that is setup by customer number and count in a sql server 2008 r2 database. Now the first program will call the second C# application and pass that program the customer number.
 
When the second C# program runs, it will obtain the customer number from the arguements that where passsed to it. Now the second C# program will read the Customer table to obtain the row that was inserted into the customer table by the first C# program.
 
This process will continue until all of the customer records have been processed.
 
The second program will now call a web service with this information. This design needs to stay since 95% of the entire new design has been tested and works. This design will stay since it will make the code production ready within a few weeks.
 
My question is updating and accessing the customer table. Will I have any deadlock issues? Do I need to consider permission problem(s) and/or access problems that I need to consider? If so, what are the problems and what do I need to do to solve the problem(s)?
QuestionQuartzTypeLib and subtitlesmemberaudaijihad30 Sep '12 - 6:22 
Hi everyone,
I want to make a simple media player in C# and I used QuartzTypeLib library to read the video and this perfect. But, in the next step I want my player to support ability to add subtitle to the movie.
 
I googled it but i didn't find any thing that simple and useful for me.
Can any one help, please.
 
Thanks in advance.
AnswerRe: QuartzTypeLib and subtitlesmemberRavi Bhavnani30 Sep '12 - 6:47 
Does answer # 9 in this[^] thread help?
 
/ravi
My new year resolution: 2048 x 1536
Home | Articles | My .NET bits | Freeware
ravib(at)ravib(dot)com

GeneralRe: QuartzTypeLib and subtitlesmemberaudaijihad30 Sep '12 - 11:33 
I think yes.
 
the second solution(I know it before) is better but i can't know how to use in C#. If you give me a link for that, please.
 
The first solution I don't understand completely but I prefer to use the first solution.
 
Thanks in advance.
QuestionUpdating a Label in 2 forms simultaneouslymemberCSharpNewbie 229 Sep '12 - 21:37 
Hi,
Here is my question...
I need to design two windows forms applications in such a way that the Form 1 will run for some time and then starts Form 2 in a new thread. Once the Form2 is started I need to update the labels on both the forms simultaneously.
 
Form1
 
public Form1()
{
Initialize();
DoSomeOperations();
}
 
public void DoSomeOperations()
{
updateLabel("Form 1");
Thread.Sleep(10000)
var task1= new Thread (() =>Form2()) {"GUIThread"};
task1.Start();
}
 
public void Form2()
{
Form2 f2= new Form2();
Application.Run(f2);
}
void updateLabel(string message)
{
label1.text = message; //label in Form1
label1.Refresh();
 
}
 
After Form2 is started, I wanted to update the label in Form 1 and Form2 at the same time. That is what ever message I get in Form 1, I need to display it both on Form 1 and Form2. I tried toraise an event in Updatelabel method and assigned the event to a method in the constructor of Form2 but it didnt work. Can somebody please help me with this?
 
Thanks in advance
AnswerRe: Updating a Label in 2 forms simultaneouslymemberSmart Arab29 Sep '12 - 22:40 
Take a look Here[^] And Here[^]

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid