Click here to Skip to main content
13,287,592 members (48,003 online)

Comments by George Swan (Top 150 by date)

George Swan 22hrs ago View
Have you considered implementing Scram-SHA-1 as an authentication method? There is a good article at
George Swan 3 days ago View
One approach for generating unique random numbers within a given range is to place all the numbers in the required range into an array. Shuffle the array and take the required items consecutively from the array.
George Swan 3 days ago View
Could I suggest that to return an array you need to add the extension method ToArray() to the query. As it stands, newArray is an IEnumerable?
George Swan 4 days ago View
George Swan 11-Nov-17 7:34am View
shouldn't that be
George Swan 11-Oct-17 4:16am View
Good answer. The term ‘embedded’ may be confusing because there are both ‘Resource’ and ‘Embedded Resource’ options for creating a Resource. I feel that the best option for WPF is ‘Resource’ because it integrates better with WPF’s file management service. Both options create an embedded resource, in the sense that they become an integral part of the assembly.
George Swan 17-Sep-17 12:18pm View
Ok, thanks. In any event, there was some activity that caused the question to get through my 'Active' filter.
George Swan 17-Sep-17 3:39am View
I can see what has happened now. The OP updated his question.
George Swan 17-Sep-17 3:35am View
Whoops, sorry. Didn't realise. I'll leave it up as it may be useful. Best wishes, George.
George Swan 26-Aug-17 2:49am View
Good point, Graeme. But isn't the pattern for using async methods similar? I must confess that I have never used WebForms.
George Swan 26-Aug-17 2:13am View
This link is also useful
George Swan 23-Aug-17 4:33am View
The string.Join method will consecutively convert every int in your array to a string and will join it to the next int using ", " as a separator. You end up with a string similar to this "1, 2, 3" being returned from the method. Console.WriteLine then prints it.
George Swan 23-Aug-17 1:09am View
Shouldn't the replacement be Console.WriteLine(string.Join(", ".res));
George Swan 24-Jul-17 1:09am View
I'm not quite sure what you are trying to achieve. Based on my best guess, I would suggest the following. Make your linked list a public property of your Box class. To add an item, first search the tree. If a match is found, add the new node to the found node's linked list. If there is no match, add the new node to the tree.
George Swan 21-Jul-17 23:55pm View
Make sure that the signature of the base class method that you are overriding, ModItem.SetDefaults(), is declared using either the virtual, abstract or override keyword.
George Swan 18-Jul-17 13:46pm View
Is this answer original or have you copied it from
c# - Is there a way to check if a file is in use? - Stack Overflow
George Swan 15-Jul-17 4:48am View
I'd use Split like this
string path = @"C:\Users\CoolDude\Documents\Access\Test.pdf";
int count = path.Count(c => c == '\\');
ArraySegment<string> splitArray=new ArraySegment<string>(path.Split('\\'),count-2,3);
string pathResult= string.Join("\\", splitArray);
George Swan 12-Jul-17 15:57pm View
Try this
user =(ParseObject) results; // here is error msg
George Swan 3-Jul-17 4:08am View
Ok, I will bin it as the tag is SQL and I know next to nothing about that ;(
George Swan 3-Jul-17 4:03am View
Shall I delete it?
George Swan 3-Jul-17 4:00am View
Sorry about the Linq tag, Maciej. I always regard Linq as being an integral part of C#. For me, it's one of the best features:)
George Swan 26-Jun-17 3:49am View
When you joined the two xml files you duplicated the declaration statement and root element. I suggest you correct this by removing the second declaration statement and adding a new root element. The XPathExpression ".//ParsedDataElement [Name='light']" should then enable you to extract the light values.
George Swan 23-Jun-17 15:59pm View
I don’t think it is wise to be stopping and restarting threads. Those sort of actions block threads and cause inefficient use of the thread pool. My recommendation, for what it’s worth, would be to abandon the use of the BackgroundWorker and adopt the modern asynchronous techniques provided by the Task based async await asynchronous framework. These techniques give sufficient abstraction for you not to have to marshal threads directly.
George Swan 19-Jun-17 12:38pm View
Try this. Wrap a ScrollViewer around the ListView. Set the Margin and Height inside the ScrollViewer tag and remove the Margin and Height references from the ListView as well as the ScrollViewer.CanContentScroll="True" reference.
George Swan 19-Jun-17 5:16am View
Sorry, I have not used email sending software before so, unfortunately, I cannot be of assistance.
George Swan 16-Jun-17 2:44am View
Yes, but I can't say for certain that I will be able to answer it!
George Swan 15-Jun-17 1:55am View
Try this
clientContext.Credentials =(ICredentials) new SharePointOnlineCredentials("", passWord);
George Swan 6-Jun-17 16:15pm View
If you know approximately how many numbers you need you can download a set from
George Swan 22-May-17 14:19pm View
I agree with your sentiments entirely. However, my approach would be to pass onto the next question without reprimanding the poster who is acting within the forum rules. It has been good chatting with you. Best wishes, George.
George Swan 22-May-17 12:55pm View
It was just that Griff said that we don’t do your homework. So I assumed that it must be against the rules. But I looked at the rules and couldn’t see it, then I sought clarification -which you kindly gave me. Thank you. So, now that you have replied and it’s clear that we have a right to post solutions to homework, another question arises. Namely, who are the ‘we’ in, ‘we do not do your homework’?
George Swan 22-May-17 11:41am View
I’m confused. Can someone please point out where in the rules does it state that homework questions must not be answered?
George Swan 20-May-17 4:35am View
An excellent well-constructed solution, +5
George Swan 20-May-17 2:44am View
Check that TextBox1.Text does not contain control characters such as 'return' or 'newline'
George Swan 8-May-17 9:31am View
Thanks for the humorous reply. I was expecting a reprimand for responding to the question. Most don't realise just how useful Linq can be so I thought I'd post it up as an example.
George Swan 30-Apr-17 2:03am View
Try renaming the variable 'b' to 'choice' and have another look at your code. It's important to give your variables meaningful names.
George Swan 3-Apr-17 11:00am View
It looks like you are trying to update a control created on the WPF UI thread from a control created on the WinForms UI thread. I think you may need to use Invoke.BeginInvoke. There is an explanation here .
George Swan 6-Jan-17 9:44am View
Looks like you have not downloaded the remote debugger msvsmon.
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.
George Swan 9-Jun-16 2:09am View
If you want to close a WPF application, just call
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.
George Swan 1-Jun-16 4:14am View
Is this tip helpful?
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.
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)
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 =
.Where(dr => string.Compare(dr.Field<string>("name"), "A", StringComparison.Ordinal) < 0)
.OrderBy(dr => dr.Field<string>("name"))
.Select(dr => dr.Field<string>("name"))
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
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
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
George Swan 22-Aug-15 2:53am View
I would suggest that you have a look at this article
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
George Swan 18-Jul-15 17:43pm View
Have you tried this?
DateTime dateTime = DateTime.ParseExact(
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
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
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 .
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 :-
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
Your 'for' statements look to be incorrect. Try : for (i=0; i<entry; i++). Arrays are zero based, so the range is 0 to entry-1 where entry is the number of entries
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;
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=>;
TestFunctions[1] = c=>;
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?
George Swan 23-Jan-15 9:16am View
Have you seen this article on how to reduce flickering?
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
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.
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
It looks like Linq is built for comfort, not speed.
George Swan 21-Nov-11 2:12am View
Have you seen this excellent Snippet Designer plugin
George Swan 4-Oct-11 2:46am View
Shouldn't the tbxAnswer.Text = total.ToString("n0"); statement be outside the while loop?
George Swan 12-Sep-11 2:11am View
Could I ask, why can't you use the default TreeView Sort method? mytree.Sort();
George Swan 9-Aug-11 2:21am View
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
Shouldn't the IfLengthInRange extension method use the && operator and not the || ?
George Swan 5-Jul-11 1:54am View
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
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
Think there are syntax errors in the code. list.Aggregate should be sList.Aggregate?

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid