Click here to Skip to main content
12,622,535 members (28,559 online)

Comments by George Swan (Top 113 by date)

George Swan 25-Nov-16 14:51pm View
   
Are you testing a variable for null that is not a reference type?
George Swan 20-Nov-16 1:12am View
   
I would suggest that 'w' should be >0 &<=1. Values greater than one tend to make the factor too dominant as there is no random fractional multiple in that part of the algorithm. Selecting the value of 'w' is not an exact science, it's a finger in the air exercise.
George Swan 20-Nov-16 0:51am View
   
Why not try to solve this by lateral thinking? Instead of finding zero directly, detect its presence by using the unique property of adding zero to a total. Is that method more efficient than using index values? It's always a good idea to look for alternative solutions, the obvious ones are not always the best.
George Swan 17-Sep-16 1:46am View
   
Are you sure this solution is correct? You are calling the same adapter.Fill method twice in the last 3 lines of your code.
George Swan 15-Aug-16 17:05pm View
   
I would suggest using lookup tables to both find and store the results.
https://en.wikipedia.org/wiki/Lookup_table
George Swan 9-Jun-16 2:09am View
   
If you want to close a WPF application, just call
Application.Current.Shutdown();
George Swan 7-Jun-16 17:40pm View
   
I'm not sure exactly what you are trying to achieve but I recently wrote a piece on the use of the async and await keywords, which may be helpful.
http://www.codeproject.com/Articles/1097427/Asynchronous-Programming-Getting-to-grips-with-Asy
George Swan 1-Jun-16 4:14am View
   
Is this tip helpful?
http://www.codeproject.com/Tips/1080653/Get-a-List-of-Dates-for-the-Nth-Desired-Day-of-W?msg=5205927#xx5205927xx
George Swan 22-May-16 15:53pm View
   
I suggest you have a look at how to use interaction requests to implement popup Windows using the Prism framework. It avoids the sort of problems you are getting as the dialog is implemented as a user control that's a child of the parent window.
https://msdn.microsoft.com/en-us/library/ff921081(v=pandp.40).aspx
George Swan 22-May-16 3:25am View
   
Can you please post some xaml so we can see what your settings are?
George Swan 7-May-16 1:33am View
   
Very neat, Bill, 5
George Swan 26-Apr-16 17:20pm View
   
bool isBool = (testString == "0" || testString == "1");
George Swan 20-Mar-16 3:23am View
   
Could I suggest that you use an established CSV library for processing your file? It may also be advantageous to have the first line of the file contain the column names. Then, for each line in the file, the library can return a class instance with property names set to correspond to the column names and values to the data in the corresponding column. Any formatting errors will be flagged with reference to the line number and column name.
George Swan 29-Feb-16 4:40am View
   
This can be simplified by having a single int[128] array and by using the char value directly as an index.
static void count_char_occurrences_in_string(string char_string)
{
foreach (char c in char_string)
{
char_counts[c]++;
}
}
You then simply filter the non-printable characters by using char.IsControl(c) method when you do the display.
George Swan 9-Feb-16 4:30am View
   
Well done, Jochen, that's exactly what I would have suggested. You are very brave answering a homework question on here. The last time I did that I received a reprimand from the forum police and multiple penalty points. Have a 5 from me and good luck to you.
George Swan 13-Jan-16 2:27am View
   
Write permissions can cascade down to subdirectories from the parent directory. Try moving your project to a subdirectory of your documents folder.
George Swan 8-Jan-16 2:34am View
   
Have I got this correct? In the Command class,the Action() delegate is invoked by invoking another Action delegate that takes an object as a parameter and calls the Action() delegate but the object is never used? This seems very messy.
George Swan 24-Dec-15 14:38pm View
   
You are quite right with your suggestion, Bill. This is much quicker
var ids = _ids.Split(',');
var result=_DataInfo.Where(ids.Contains);
George Swan 20-Dec-15 13:05pm View
   
It's my fault, I didn't notice the date. If only I had your erudition I wouldn’t keep making these silly mistakes.
George Swan 20-Dec-15 12:40pm View
   
I’m sorry, Richard. The guy asked for help and I gave it unconditionally. It seems that you only help those who you feel are worthy. That can be a tough call when you know nothing about him or his circumstances.
George Swan 11-Dec-15 1:39am View
   
So are you saying that asking, how many characters are in a string is the same as asking, how long is a piece of string? Regards, George. Sorry about the frivolity, I couldn't resist it.
George Swan 9-Dec-15 1:57am View
   
I don't think you need the first 'SelectMany' this should do the trick
return peakDatas.SelectMany(pD => pD.Data).ToArray();
George Swan 12-Nov-15 15:29pm View
   
Are you sure this is correct? I would have thought that it returns the whole of List1
George Swan 4-Nov-15 15:10pm View
   
You can get the current year like this
int currentYear = DateTime.Now.Year;
George Swan 11-Oct-15 13:09pm View
   
I didn't want to post an alternative solution, Maciej, as you had already done all the hard work. Regards, George.
George Swan 11-Oct-15 10:25am View
   
As an alternative to using Regex you can do something like this
var query =
dt.AsEnumerable()
.Where(dr => string.Compare(dr.Field<string>("name"), "A", StringComparison.Ordinal) < 0)
.OrderBy(dr => dr.Field<string>("name"))
.Select(dr => dr.Field<string>("name"))
.ToList();
George Swan 10-Oct-15 3:05am View
   
This is an excellent example of the SelectMany extension. I didn't know it was so versatile. 5 from me
George Swan 6-Oct-15 16:27pm View
   
Deleted
I'm not sure what you mean by 'special characters' but the following will remove control characters from a string.
string cleanedString= new string(MyString.Where(c=>!char.IsControl(c)).ToArray());
George Swan 6-Oct-15 3:01am View
   
Could I suggest that you do the following? Use the 'dot notation' to locate the file.
var text = File.ReadAllLines(@".\MyFolder\MyFile.txt");
This reads 'MyFile.txt' from the 'executing assembly'\MyFolder
Also, use a try catch block to catch FileNotFoundException
George Swan 28-Sep-15 13:26pm View
   
Deleted
I thought I knew the answer but I didn't want to seem presumptuous.Thanks for your explanation.
George Swan 28-Sep-15 12:17pm View
   
Does this output the pattern as illustrated in the question? 5,10,15,15,20,25,20,25 etc
George Swan 28-Sep-15 12:11pm View
   
Here's a hint. Try analysing the pattern. It is made up of rows and columns. The number of columns in a row is equal to the row number, starting from row 1 at the top. The first column is the row number multiplied by 5, subsequent columns are equal to the previous column plus 5.
George Swan 20-Sep-15 16:26pm View
   
In your XML schema you have
'canumber(string)' - shouldn't that be carnumber NOT canumber
George Swan 15-Sep-15 17:19pm View
   
My guess is that Linq to Entities tries to convert the query into a SQL statement but this fails because of the ToArray() call. You need to return an enumerable and then convert that to an array. I suspect that the only reason that your second example appears to work is that there is no data to be returned.
George Swan 26-Aug-15 2:44am View
   
Can you please mark this problem as solved? As, it seems to me, that Richard has produced an excellent solution.
George Swan 25-Aug-15 2:26am View
   
This looks like a namespace problem. If namespaces are defined in the xml, you need to use a XmlNamespaceManager to access the nodes effectively. See
https://support.microsoft.com/en-us/kb/318545
George Swan 22-Aug-15 2:53am View
   
I would suggest that you have a look at this article
http://www.codeproject.com/Articles/161465/Arrays-Basics-in-CSharpDotNetTech
George Swan 19-Aug-15 17:57pm View
   
You are quite right. I copied the format from the question. 'mm' is minutes so 'yyyy-mm-dd' would allow 1999-59-02. Thanks
George Swan 2-Aug-15 11:37am View
   
Can't you just check for null in your 'Where' clause?
Where(u=>user.Name!=null && u.Name.Contains(user.Name) && user.ID!=null && u.ID==user.ID)
George Swan 1-Aug-15 2:27am View
   
It seems to me that your BackgroundWorker may finish before the timer event fires so your string variable may not be set. If you really want to keep to the structure in your example, I'd wrap the string inside a Stringbuilder object and pass that into the Authenticates_Timer method.
George Swan 23-Jul-15 1:30am View
   
Have a look at this link
http://blogs.msdn.com/b/csharpfaq/archive/2009/03/25/how-to-use-linq-methods-to-compare-objects-of-custom-types.aspx
George Swan 18-Jul-15 17:43pm View
   
Have you tried this?
DateTime dateTime = DateTime.ParseExact(
"20080521",
"yyyyMMdd",
System.Globalization.CultureInfo.InvariantCulture);
George Swan 18-Jul-15 11:38am View
   
It seems to me that your TextBlock bindings are wrong. You are binding to a public field CurrentPart.PartNumber. You should be binding to the property PartNumber in your view model. If you wish to use Current Part as your model, you need to set it and get it in your PartNumber property e.g. get{return.CurrentPart.PartNumber} set{ CurrentPart.PartNumber=value etc}.
George Swan 17-Jul-15 17:32pm View
   
Try
.OrderBy(item=>item.Element("ClosingMarketValue").Value)
George Swan 4-Jul-15 18:23pm View
   
You may need to be a bit careful here as the fractional part of an hour is often expressed as base 60, so 10.40 means 10hrs 40 minutes not 10hrs 24minutes
George Swan 19-Jun-15 11:55am View
   
Thanks, Sergey. I am very appreciative of all the help you have given to posters on here over the years. Regards, George.
George Swan 19-Jun-15 10:46am View
   
'which you did not bother to share with us.' I think that's a bit harsh, Sergey. Sumith may have just forgotten or perhaps he did not think it relevant.
George Swan 1-Jun-15 1:44am View
   
Try testing for equality in this way
bool isEqual = Math.Abs(Round1 - Round2) < 0.00002m;
George Swan 25-May-15 13:41pm View
   
I would suggest setting up your servers as replica sets. There are details of how to do this here
http://www.codeproject.com/Articles/524602/Beginners-guide-to-using-MongoDB-and-the-offic
George Swan 17-May-15 3:22am View
   
I suggest you pop up a confirmation DialogBox in response to the button click.
George Swan 12-May-15 14:24pm View
   
If possible, I'd use the Task Parallel Library (TPL) rather than the Background worker class. It's cleaner and more simple to set up.
George Swan 24-Apr-15 0:55am View
   
I feel this is a comment, not a solution. It simply expresses an opinion and does not actually solve anything. In my view, the submission is perfectly valid but it has been posted in the wrong section.
George Swan 23-Apr-15 8:39am View
   
Sascha, Thanks for clarifying when anonymous types are required in the equality statement. I take your point about the 'select' statement. Regards, George.
George Swan 23-Apr-15 5:11am View
   
I think that the equality test needs to compare properties that have the same name. So you may need to do this:
join BrugereA in db.brugeres on new {Id=VenA.From} equals new {BrugereA.Id}
Also, there is no need to create an anonymous type in the select statement, you can simply select BrugereA
George Swan 20-Apr-15 15:47pm View
   
Make sure you have not set the Height or Width properties.
George Swan 20-Apr-15 11:02am View
   
Check you are not working with a copy of the database
George Swan 20-Apr-15 1:38am View
   
Make sure you have the following using statement.
using System.Linq;
George Swan 17-Apr-15 16:00pm View
   
I'm sorry but I can't come up with any other suggestion that may help.
George Swan 17-Apr-15 12:18pm View
   
Try rebuilding all the projects in the solution.
George Swan 16-Apr-15 11:54am View
   
In the Solution Explorer window, expand 'References,' right click on Spire.Pdf, select properties, scroll to see the Version number in the 'Properties' Window. Alternatively, in the executing folder of the application, right click on Spire.Pdf.dll, select properties then the Details tab.
George Swan 14-Apr-15 12:41pm View
   
Looks like you may have the wrong version of Spire.Pdf.dll. I would locate the dll and check its version number
George Swan 13-Apr-15 5:20am View
   
I think PrimaryPersonID == null; should read PrimaryPersonID = null;
George Swan 9-Apr-15 15:01pm View
   
Go to this codeproject article .
http://www.codeproject.com/Articles/36468/WPF-NotifyIcon
Download the example project and look at the EncryptDecryptData class
George Swan 7-Apr-15 9:05am View
   
Shouldn't we think twice before censoring participants, on the grounds that we know what’s best for them? Is that sort of behaviour really appropriate in a free and open forum?
George Swan 2-Apr-15 17:07pm View
   
The URL string looks incorrect, try :-
"http://flights.makemytrip.com/makemytrip/search/O/O/E/1/0/0/S/V0/DEL_BOM_14-08-2015?intid=homepage_Widget_Search_New-Delhi_Mumbai"
George Swan 2-Apr-15 11:25am View
   
The default start up Window in a WPF project is set in the App.xaml file. Delete StartupUri="MainWindow.xaml" in the opening tag if you are using an alternative Window.
George Swan 31-Mar-15 2:40am View
   
Deleted
Your 'for' statements look to be incorrect. Try : for (i=0; i
George Swan 30-Mar-15 17:51pm View
   
This is a good well-written solution +5. You can further simplyfy the 'if' statement as: if (e.Alt && e.KeyCode == Keys.X)
George Swan 30-Mar-15 15:41pm View
   
Have you checked that the image file's build property is set to 'Resource'?
George Swan 16-Mar-15 4:45am View
   
Can you post a sample of your Vendas.xml file please?
George Swan 9-Mar-15 13:03pm View
   
It looks to me like you need to create a new E2E_Mstuserdetails object inside the 'if' statement.
entities.E2E_Mstuserdetails.Add(new E2E_Mstuserdetails{email=txt_inviteemail});
George Swan 5-Mar-15 5:04am View
   
It refers to the namespace in which the Model is defined. There should be a project in the solution with the name WinformMVC.Model or something similar.
George Swan 3-Mar-15 8:38am View
   
It is not sufficient for you to be logged on as an administrator, you need to right click on the application and select 'Run as Administrator'
George Swan 26-Feb-15 13:02pm View
   
Is the Type of account.Alias exactly the same as that of studentMaster.stdACID?
George Swan 20-Feb-15 13:46pm View
   
</p>Why not declare a new serializable class and pass the std class into its constructor to initialise the class properties that you want? Then serialise the new class.</p>
George Swan 17-Feb-15 14:44pm View
   
You need to set the height property of the ScrollViewer to some value
George Swan 12-Feb-15 1:54am View
   
The 'using' statement calls the Dispose method on your streamWriter so it is closed after your first 'using' statement
George Swan 11-Feb-15 16:59pm View
   
I think it is because you have called obj.Dispose() before closing it.
George Swan 9-Feb-15 14:58pm View
   
I suggest that you check the inner exception.
George Swan 7-Feb-15 18:21pm View
   
Have you tried changing
thistable = sortthistable;
to
thistable = sortthistable.ToList();
George Swan 2-Feb-15 15:03pm View
   
Try changing the first parameter of the EditAction method from int Idt to int? id.
George Swan 2-Feb-15 3:46am View
   
Another suggestion, if you are using a microsoft server, is to execute the statement directly in Management Studio and check the message window.
George Swan 2-Feb-15 3:38am View
   
That's true. It's a common problem with Entity Framework and the like, as they tend to pluralize table names in their classes.
George Swan 2-Feb-15 3:06am View
   
Have you checked that the table name on the server is actually 'Products' and not 'Product'?
George Swan 29-Jan-15 18:34pm View
   
It's a great solution. I'd have declared an array of delegates and indexed into the required one in the Where statement.
var TestFunctions = new Func<users, bool>[6];
TestFunctions[0] = c=>c.id.Contains(textBox7.Text);
TestFunctions[1] = c=>c.name.Contains(textBox7.Text);
//........................
var qsearch = db.users.Where(testFunctions[selectedIndex]);
George Swan 29-Jan-15 18:18pm View
   
I think you may have forgotten to compile the Expression.
var predicate = Expression.Lambda<Func<user, bool>>(check, parameter).Compile();
George Swan 26-Jan-15 13:24pm View
   
Try setting the DataGrid's DataContext in code
this.pgeDataGrid.DataContext = dTable.DefaultView ;
And setting the ItemsSource in the Xaml
<datagrid name="pgeDataGrid" itemssource="{Binding}"></datagrid>
George Swan 26-Jan-15 3:41am View
   
Sorry that I couldn't be of more help to you.
George Swan 24-Jan-15 17:28pm View
   
I cannot see where you are updating the txt_bal.Text to reflect the new balance. If txt_bal.Text does not change the txt_pstatus.Text will not be changed.
George Swan 24-Jan-15 10:07am View
   
Is this any use to you?
http://www.codeproject.com/Articles/24330/WPF-Bind-to-Opposite-Boolean-Value-Using-a-Convert
George Swan 23-Jan-15 9:16am View
   
Have you seen this article on how to reduce flickering? http://www.codeproject.com/Tips/390496/Reducing-flicker-blinking-in-DataGridView
George Swan 23-Jan-15 1:51am View
   
Could you please provide some more information?
Which column is the key that links the two databases?
Which column do you want to group the data by?
Which entries are credit and which are debit transactions?
Is the balance a running balance ordered by date?
George Swan 23-Jan-15 0:54am View
   
You are very welcome.
George Swan 23-Jan-15 0:53am View
   
You are very welcome - I'm sorry that I couldn't be of more help.
George Swan 22-Jan-15 9:26am View
   
I think that your problem arises because part of the normal functionality of the textBox is to place the caret at the position of the cursor when the left mouse button is clicked, as this facilitates editing. By changing this functionality you will lose operational consistency between related controls which may both confuse and frustrate users. My only suggestion is that, to achieve the effects you want, you may have to replace the default template for the control with your own version. This is not a trivial task. Best wishes.
George Swan 22-Jan-15 5:13am View
   
I think you may be getting confused between cursor and caret. The flashing vertical bar is the caret. Its position is determined by the caretIndex property.
George Swan 19-Jan-15 7:34am View
   
It means that your app is requesting a file that cannot be found. It could be that the JsonfilePath string is not a valid filepath
George Swan 18-Jan-15 9:15am View
   
Pleased you have managed to sort it out.
George Swan 17-Jan-15 5:57am View
   
I think you are doing this the hard way. Try downloading FileHelpers from https://github.com/MarcosMeli/FileHelpers
With FileHelpers.dll you can the read your file straight into a Proccess[] with just a couple of lines of code and it's free.
George Swan 13-Jan-15 2:22am View
   
As it stands, your test does not actually test anything. You need to Assert (test) that some value is correct or that a certain method has been called. Unit tests should run entirely in memory and not rely on external services such as a database. A useful technique is to fake the database and to test that the values passed to it are correct. In effect, you are testing how your program relates to the database rather than testing the database itself. It’s good to keep the statements simple so as not to introduce bugs into the test.
George Swan 12-Jan-15 12:12pm View
   
I'm keen to improve my coding so I would be most grateful if the guy who down-voted this solution could please explain the reason why.
George Swan 9-Jan-15 1:29am View
   
I suggest that you have a look at the Prism QuickStarts, especially the interactivity sample.

http://msdn.microsoft.com/en-us/library/gg430879(v=pandp.40).aspx
George Swan 9-Jan-15 1:20am View
   
I suggest that you add the above code to your method and return the GroupModel list instead of the IQueryable. Best wishes.
George Swan 7-Jan-15 5:44am View
   
I would suggest that the reason that your 'not implimented' method is being called is that there is an implicit conversion between a byte array and a Binary, so the method will accept both types. I suggest that you remove that method and convert any Binary you may wish to use to a byte[] before passing it to the other method. You can use the binary.ToArray() method to do the conversion.
George Swan 11-Jan-12 12:00pm View
   
Deleted
It looks like Linq is built for comfort, not speed.
George Swan 21-Nov-11 2:12am View
   
Deleted
Have you seen this excellent Snippet Designer plugin http://snippetdesigner.codeplex.com/
George Swan 4-Oct-11 2:46am View
   
Deleted
Shouldn't the tbxAnswer.Text = total.ToString("n0"); statement be outside the while loop?
George Swan 12-Sep-11 2:11am View
   
Deleted
Could I ask, why can't you use the default TreeView Sort method? mytree.Sort();
George Swan 9-Aug-11 2:21am View
   
Deleted
Hasn't Blowfish been replaced by the AES compliant ciphers such as Twofish and Rijndael? So why not use the Aes class as detailed here?
George Swan 5-Jul-11 5:24am View
   
Deleted
Shouldn't the IfLengthInRange extension method use the && operator and not the || ?
George Swan 5-Jul-11 1:54am View
   
Deleted
I think a typo my have crept into the spelling of maintenance both in the heading and the code blocks.
George Swan 28-Jun-11 12:59pm View
   
Deleted
Sorry Charles, I thought the subkey already existed. I've tested my new version and it now works ok . Best wishes George.
George Swan 24-Jun-11 2:16am View
   
Deleted
Think there are syntax errors in the code. list.Aggregate should be sList.Aggregate?

Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid