15,742,316 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Javascript questions
View C++ questions
View Python questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Andrew Rissing (Top 122 by date)
Andrew Rissing
1-Apr-13 12:22pm
View
Reason for my vote of 1 \n I'm sorry. Until this is thread safe, I would not recommend this for use. Please reply to this after it has been fixed, and I will adjust my vote.
Andrew Rissing
14-Sep-12 16:13pm
View
Either way, they would be handled properly. The finalizer would be only called if Dispose was somehow missed.
It is up to you whether or not to use the additional using statements for completeness, but ultimately they really shouldn't be necessary.
Anyways, enjoy the weekend. I'll be there shortly myself.
Andrew Rissing
14-Sep-12 15:58pm
View
Cool. I will say though that GZipStream and CryptoStream both dispose of any Stream objects passed to them, so the use of layered using statements would be redundant. Worst case scenario, if the dispose method failed to complete successfully (an entirely exceptional situation here), the finalize method would eventually kick in as a saving grace.
Food for thought.
Andrew Rissing
14-Sep-12 15:16pm
View
Thanks. :)
Andrew Rissing
14-Sep-12 14:06pm
View
I don't believe I've heard any mumblings of this behavior changing any time soon. So, you are likely safe for sometime.
Btw, are you using this to conditionally encrypt/compress your output? Or is this for something else?
Andrew Rissing
31-Jul-12 19:57pm
View
I caught the problem, hence the comment about syntax. ;-)
Andrew Rissing
16-Mar-12 10:10am
View
The equation you posted is a bell curve. I'm not following what you're asking then....
Andrew Rissing
14-Mar-12 10:39am
View
Problem, what happens when the phone is accidentally dropped? There isn't really a clear way to determine the difference between the two situations.
Andrew Rissing
26-Jan-12 12:46pm
View
Deleted
Perhaps it would make it completely obvious looking at the code for Dictionary's ContainsKey/Indexer vs. TryGetValue.
public bool ContainsKey(TKey key)
{
return (this.FindEntry(key) >= 0);
}
and
public TValue this[TKey key]
{
get
{
int index = this.FindEntry(key);
if (index >= 0)
{
return this.entries[index].value;
}
ThrowHelper.ThrowKeyNotFoundException();
return default(TValue);
}
set
{
this.Insert(key, value, false);
}
}
vs.
public bool TryGetValue(TKey key, out TValue value)
{
int index = this.FindEntry(key);
if (index >= 0)
{
value = this.entries[index].value;
return true;
}
value = default(TValue);
return false;
}
So, you can see it does the same work (minus one additional call to FindEntry), but all in one single call.
Andrew Rissing
26-Jan-12 12:33pm
View
Deleted
If you use TryGetValue, it uses an out parameter to set the value and returns true, otherwise it returns a false and sets the out parameter to default.
By doing this, you access the dictionary once to see if the key exists and get the value if its there, rather than checking if the key exists and then later accessing it again to get the value. Do some performance testing, you'll see it is much faster to do it this way.
Furthermore, its easier to read:
if (!dct.TryGetValue(key, out value))
{
dct[key] = value = ....;
}
// value will always be set to something valid here.
Andrew Rissing
26-Jan-12 11:13am
View
Deleted
If you do update this, I'd recommend using "TryGetValue" rather than using "ContainsKey", as it would yield a better performance.
Andrew Rissing
26-Jan-12 9:49am
View
Deleted
Based on a comment by nonexisto, I realized that the constraint doesn't allow private constructors. So, the constraint isn't useful if you're intending this to work for classes with a hidden default constructor. If you're using this for public constructors, then you definitely don't need all of this to initialize the class.
Andrew Rissing
26-Jan-12 9:39am
View
Deleted
Corrected. I removed the type constraint. I didn't realize it wouldn't apply private constructors. As for the code, it is definitely still applicable, as the code was designed for accessing a private member (hence the reference to Activator.CreateInstance).
Andrew Rissing
26-Jan-12 9:37am
View
Deleted
Ignore that, nm...that would only apply to a public constructor.
Andrew Rissing
25-Jan-12 21:49pm
View
Deleted
Btw, you might want to add a default constructor constraint (i.e. where T : new()).
Andrew Rissing
25-Jan-12 15:36pm
View
Deleted
The overhead in your method may likely be due to the dynamic keyword usage.
But either way, here is the code I used to test it:
-----------------
var sw = Stopwatch.StartNew();
for (int i = 0; i < 1000; ++i)
{
List<string> x = DynamicInitializer.New<List<string>>();
}
sw.Stop();
Console.WriteLine("New<t>: " + sw.ElapsedMilliseconds);
var di = new DynamicInitializer();
sw = Stopwatch.StartNew();
for (int i = 0; i < 1000; ++i)
{
List<string> y = di.NewInstance<List<string>>();
}
sw.Stop();
Console.WriteLine("NewInstance<t>: " + sw.ElapsedMilliseconds);
Console.ReadLine();
-----------------
Testing it again, it seems the values are much closer now - ~150ms vs ~220ms. But using Expressions, still wins out. It roughly equates to being 20% faster than the original code. It doesn't seem to vary much with different types or release/debug builds, so I'd be curious if you find where the difference you're speaking of shows up.
If I take your code and rewrite as follows:
public V NewInstance<V>() where V : class
{
var type = typeof(V);
var target = type.GetConstructor(Type.EmptyTypes);
var dynamic = new DynamicMethod(string.Empty,
type,
new Type[0],
target.DeclaringType);
var il = dynamic.GetILGenerator();
il.DeclareLocal(target.DeclaringType);
il.Emit(OpCodes.Newobj, target);
il.Emit(OpCodes.Stloc_0);
il.Emit(OpCodes.Ldloc_0);
il.Emit(OpCodes.Ret);
var method = (Func<V>)dynamic.CreateDelegate(typeof(Func<V>));
return method();
}
It improves the timing from ~220ms to ~190ms.
Andrew Rissing
25-Jan-12 15:19pm
View
Deleted
I would disagree with statics being considered a bad practice. If you're not planning on trying to 'derive' them and they are purely utility in nature, statics are fine. Best practices should always be considered but not dogmatically followed.
Andrew Rissing
25-Jan-12 13:40pm
View
Deleted
Btw, you can mark these as all static.
Andrew Rissing
16-Jan-12 10:25am
View
Deleted
It is generally not a good practice to reference items off of a disposed object. Plus, you can return within a using clause, as the objects will properly be disposed. You need to correct your ZipFilesToByteArray method to be as such:
public static byte[] ZipFilesToByteArray(IEnumerable files, CompressionOption compressionLevel = CompressionOption.Normal)
{
using (MemoryStream memoryStream = new MemoryStream())
{
ZipHelper.ZipFilesToStream(memoryStream, files, compressionLevel);
return memoryStream.ToArray();
}
}
Andrew Rissing
12-Jan-12 10:58am
View
Deleted
It isn't about feelings, so much as etiquette in general. I don't personally care about the vote. I understand that it is an edge case for someone to want to do this. You are absolutely correct about the risk involved in using such, but like any tool its usefulness and effectiveness should be judged in the context of its use. So, like I started with, to each his own.
Andrew Rissing
12-Jan-12 9:35am
View
Deleted
I think "All Time Programming" states it correctly. There are times when you will 'tighten' the screws on something that needs to be performant. But if this is called 2 times in the entire lifetime of an application, such code would be over-engineering. Because the original intent of the author was to place this into a constructor, it would seem you're likely to construct the object more than a few times, so I sought to derive a solution that removes the overhead of reflection. Regardless, I don't feel a vote of one is warranted based on one aspect of the code, when it will easily outperform the reflection based solution.
I liken it to saying that all trucks are worthless because they have poor gas-mileage. But have you tried moving your couch in a Prius?
Andrew Rissing
11-Jan-12 17:44pm
View
Deleted
Bah, System.Drawing *shakes fist*. I should have attempted before posting.
Andrew Rissing
10-Jan-12 11:11am
View
Really, it's 2007 and up (not just 2010). Basically, if the extension has an "x" in it (.docx, .pptx), you should be able to use the OpenXml API.
Andrew Rissing
10-Jan-12 10:06am
View
Deleted
Ignoring the issues with not using SQL parameters, why not just do the math prior to the string.Format and save the database from computing it?
Andrew Rissing
10-Jan-12 9:59am
View
Deleted
I would gladly see an alternate of yours that would accomplish the same goals with as much performance and elegance. Granted, to each his own, but I feel such a vote is unwarranted.
Andrew Rissing
9-Jan-12 21:01pm
View
Deleted
I'll definitely consider it, just need to find the time to do it.
Andrew Rissing
9-Jan-12 10:56am
View
Deleted
If you're going to save off the Regex and use it more than once, compiled should always be faster. Otherwise, uncompiled should be used for the best performance.
Andrew Rissing
5-Jan-12 9:53am
View
Deleted
I've posted the code to what I was describing below for your perusal.
Andrew Rissing
4-Jan-12 17:47pm
View
Deleted
It would just rely on what you described above to acquire what the default value was. So, it isn't any different from the above aside from pushing the setting of those values into a cached expression that will read the DefaultValueAttribute only once on the first hit.
Reflection is always slow, furthermore TypeDescriptor has additional overhead over regular reflection as well, which is partly due to the caching it does internally.
Andrew Rissing
4-Jan-12 13:40pm
View
Unfortunately, yes. You have to consider that the Excel file format is proprietary. It's actually kind of nice that Microsoft even gave people a way to read the files without having to have Excel installed (for everything other than Interop).
Btw, OLE Jet is probably the simplest to get up and running, so give that a whirl.
Andrew Rissing
4-Jan-12 13:15pm
View
Deleted
If you really wanted to go hog wild, you could go this route...
1) Create a static class that maintains a static dictionary with a key of type and value of Action.
2) In the class create a generic static method called Initialize<t>(this T item) (or whatever you like).
3) In the static method Initialize, you'll create an Action<t> using Expressions that will do the above, but cache the compiled expressions in the dictionary from line 1. If it already exists in the dictionary, just retrieve it.
4) Cast the Action to Action<t> (thanks to the generic method).
5) Pass in the item parameter and viola.
Granted, this is probably an overkill. It would greatly improve performance, as this would be called upon each object's construction.
Andrew Rissing
4-Jan-12 10:23am
View
I've fixed the link for him.
Andrew Rissing
6-Dec-11 9:55am
View
Deleted
Code coverage. As in, the percentage of the code covered (or executed) through a unit test. See http://en.wikipedia.org/wiki/Code_coverage.
Andrew Rissing
18-Nov-11 9:43am
View
Right, if you just copy those Dll's over and they have .NET 3.5 or greater, they should be able to use your executable.
Andrew Rissing
3-Nov-11 22:05pm
View
You also need to handle the namespace issue.
Andrew Rissing
1-Nov-11 11:14am
View
Deleted
Indeed, I have. Oddly enough, your alternate was removed. *shrug*
Andrew Rissing
28-Oct-11 10:15am
View
Deleted
Personally, if you were going to go that route. I'd still try to drop the 'last' parameter from being passed in. It is just extra baggage for someone to maintain in order to call your method.
One solution I can see would be to override a StringReader. The index would still be maintained internal to that object, but at least they don't have access to modifying it or incorrectly passing it back in. The parameter just strikes me as exterior to finding items in a string.
Andrew Rissing
28-Oct-11 10:06am
View
Deleted
Easy enough to do. It is a minor code smell, but smelly it shall be. :)
Andrew Rissing
28-Oct-11 10:00am
View
Deleted
Actually, because you treat String.Empty as the end. You probably had it like that on purpose. You'd have to use null or some such to overcome that limitation.
Andrew Rissing
27-Oct-11 22:58pm
View
Deleted
Just a heads up, you might want to review the code:
-GetBetween - You have an extra + 1 on the second argument for computing endIndex.
-GetBetweenExcludeTokens - You didn't subtract the start.Length on the return.
Andrew Rissing
27-Oct-11 11:23am
View
Deleted
While Alternative 4 will only load the instance when it is called, it could have some concurrency issues as two threads could call it instantiating two separate instances. Alternative 3 would not have concurrency issues, but would instantiate the instance the first time the class type is referenced in code.
Andrew Rissing
24-Oct-11 23:41pm
View
Deleted
This is very limited to a specific flavor of CSV (ex. ones that don't include, comment rows, quoted columns, etc.) and relies on MessageBoxes and Application.Exit to control flow.
If you're going to go through the hassle of parsing it to validate it, why not get the parsed values as well using one of the many parsers available from Codeproject or the internet?
Andrew Rissing
22-Oct-11 21:07pm
View
I was shooting in the dark with some significant assumptions about the data. If the data covers all of the ranges of the Velocity, Note, Channel values, the sorting would be based upon the three lower bounds of the Region (LoVelocity, LoNote, and LoChannel). It would be analagous to a clustered key in a database.
Andrew Rissing
21-Oct-11 23:08pm
View
Please forward requests to http://www.infinityward.com/. As they would be the only ones to add an in game message system.
Andrew Rissing
21-Oct-11 22:46pm
View
See my comment above about short circuiting. I would agree whole heartedly with the statement about using a different data structure. I don't see a dictionary working out well if he has a large collection of data. It is just hard to say much with so little information provided.
Andrew Rissing
21-Oct-11 22:42pm
View
The above should not improve performance what so ever and may actually decrease it. The && operator in C# automatically short circuits in cases where it can. See: http://msdn.microsoft.com/en-us/library/2a723cdk(v=VS.100).aspx.
Andrew Rissing
21-Oct-11 16:23pm
View
Np, I should have just commented on the original question. No biggie. Thanks for the +5 :)
Andrew Rissing
21-Oct-11 14:23pm
View
Yeah, I've seen that issue before as well. It's very annoying. But at least, you've fixed it.
Andrew Rissing
18-Oct-11 19:46pm
View
Deleted
Did you just create your own data structure and perform the calculations using the "by hand" algorithm?
Andrew Rissing
18-Oct-11 19:42pm
View
Deleted
I knew it would. I just didn't want to change the context of the original solution. Either way, not a big deal.
Andrew Rissing
12-Oct-11 15:00pm
View
Deleted
Updated :)
It is essentially now what cechode put forth, but meh. :D
Andrew Rissing
12-Oct-11 10:01am
View
Deleted
;-)
Andrew Rissing
12-Oct-11 9:53am
View
Deleted
Sorry, initially read your comment as referring to Cechode's not Rodriguess'. But essentially the comments still stand as well. I did do a performance test and mine was twice as fast as Rodriguess' as well. Most likely due to the fact that he's updating a list to maintain which items have not been removed yet.
Andrew Rissing
12-Oct-11 9:47am
View
Deleted
There is no need to run performance testing against the two. You can visually inspect them and see that it would be more performant.
1) It isn't allocating a new object for each member of source.
2) It is performing a subset of the operations in cechode's version.
Just for the fun of it, I went ahead and did some performance testing. In terms of speed, it is at least an order of two times as fast.
Andrew Rissing
11-Oct-11 16:19pm
View
Deleted
Corrected above. Thanks for the catch.
Andrew Rissing
14-Sep-11 9:53am
View
Deleted
This only works though from within the class that defines the event.
Andrew Rissing
1-Sep-11 10:23am
View
Deleted
Ah, but that assumes you're shipping release code... :-D
Andrew Rissing
25-Aug-11 6:32am
View
Well, you could tie into the event you're using to zoom and change the size of the sphere.
Or just leave it as is. Because if I zoomed in on a point, I would expect it to grow.
Andrew Rissing
24-Aug-11 22:22pm
View
Shooting from the hip here without actually trying, you could make the start/end points to be at the same. If that doesn't work, you might be better off making a sphere and just making it rather small. Just a few ideas.
Andrew Rissing
10-Aug-11 12:53pm
View
Np, updated vote/etc./etc.
Andrew Rissing
10-Aug-11 12:47pm
View
You might want to validate your claim there about the getter always being called because its not true. Unless you did something like "StageFromId++" (which is just syntactic sugar for "StageFromId = StageFromId + 1") a getter will never be called on a set.
Andrew Rissing
8-Jul-11 15:02pm
View
Right, if he has the source to the referenced assembly, he can just update the AssemblyInfo.cs there. If he didn't, he could as easily change the reference in his project to not care about the specific version.
I assumed the latter was the once most likely to resolve his issue, unless he has an overly complex setup.
Andrew Rissing
7-Jun-11 9:22am
View
Sometimes when people pose such broad questions without details, I just get it in me to reply in like with my answers. ;-)
Andrew Rissing
18-May-11 10:00am
View
Gets the HREF? :D
Andrew Rissing
12-May-11 6:37am
View
Deleted
Agreed, it should have been supported in some way.
As for the recomputing of compositeValues, it would be easy to implement a cache for those values.
Andrew Rissing
5-May-11 15:06pm
View
It'd be easy enough to pad the value with a zero if its odd (or something else equivalent), if the input is considered valid if it is an odd number of characters.
Andrew Rissing
23-Apr-11 16:42pm
View
The two options you have if you want that feature is to fill in the gaps in C# or create a SQL stored procedure that will provide a table of all the dates you need as a result to join up with. You would take the list of all the dates you need and LEFT JOIN it with data provided in the query above.
Andrew Rissing
22-Apr-11 21:27pm
View
Assuming I did it correctly without executing it, it should result in a date string of the format "JAN 2009". You can break it up as you have in what you provided. It just depends on what you want it to be. I tried to get it as close as to the original output you were looking for.
Andrew Rissing
19-Apr-11 22:01pm
View
It might help you find an answer if you try to make the question (including code) as readable and straight forward as possible. I've tried to help by adding pre tags, but there is still much to be desired for someone to invest wading through this question to find what you need.
Andrew Rissing
19-Apr-11 16:54pm
View
jspano may correct us, but the issue described was not for cross-thread communication but for interacting with UI elements from a background worker. So, based on my interpretation, the solution is accurate and complete. :)
Andrew Rissing
19-Apr-11 10:48am
View
Deleted
Just fyi, it will cause 64-bit Vista to crash running this...
Andrew Rissing
5-Apr-11 9:51am
View
Deleted
You might want to do some comparisons in performance, because I believe "info.GetValue(obj, null)" will be orders of magnitude slower than expression-based alternatives.
Andrew Rissing
4-Apr-11 17:06pm
View
Deleted
This isn't a tip/trick, but a blog post. I'd delete it and have CP pull the info from your blog directly.
Andrew Rissing
30-Mar-11 9:42am
View
Deleted
Definitely makes more sense if you are doing an operation that is more complex.
Andrew Rissing
29-Mar-11 11:46am
View
Deleted
I'll keep an eye out for the update, because at this point I'm not seeing the benefit.
Andrew Rissing
29-Mar-11 10:01am
View
Deleted
I agree with Jose. While interesting academically, what is the use of something like this when you could just "&&" the results together?
Andrew Rissing
16-Mar-11 15:12pm
View
Deleted
Thanks for pointing out the extra ToArray. I have removed it, since it is not needed.
Andrew Rissing
11-Mar-11 10:14am
View
Deleted
While I haven't tested it for performance, it may very well be more performat than relying on a DataTable to do the sorting, since it has to parse the string passed into the "Select" method. I mainly was trying to get away from having to pass the sort column as an integer and then the sorting direction as a string. Furthermore, using the above style is very much inline and natural for someone who is use to Linq's OrderBy extension methods.
Btw, I've updated my alternate to provide a more complete picture of what the code would be and an example of how to use it.
Andrew Rissing
1-Mar-11 9:47am
View
Deleted
The Timer class you've listed is the Stopwatch class. The only reason you would need this if you're working on a .NET version that doesn't provide that class already.
Andrew Rissing
24-Feb-11 9:16am
View
Deleted
Assigning null to a variable is very inexpensive. In every case I've seen it used, it reduces readability and lacks any real benefit. The ultimate point I'm trying to make is that do something because it has some reason or benefit. The more you bloat code with 'this is what I've always done' kind of things, you end up confusing those looking at your code. They can't tell the vital pieces of code from the noise that is left over from a coding habit.
Andrew Rissing
23-Feb-11 14:54pm
View
Deleted
There would be no need. The garbage collector would take care of it, once it is no longer referenced. Since it is a local variable, it will no longer be referenced at the end of the method. Assigning null is extraneous and a relic of VB coding.
Andrew Rissing
23-Feb-11 9:27am
View
Deleted
Aside from going row then column, the code is equivalent to the original post. The code was just refactored to remove out unneeded statements and take advantage of the using statement to make it easier to read. The performance should be essentially equivalent.
Andrew Rissing
16-Feb-11 9:14am
View
Deleted
Checking the state is unnecessary. The calling "Close" twice on a connection doesn't throw an exception. Plus, there are only two ways to close the connection. One is the normal path without exceptions where the "Close" immediately after the ExecuteNonQuery (which even this could be omitted if you favored leaving it up to the dispose of the SqlConnection). The other way is the exceptional, which is where the dispose will correctly close the connection for you.
Andrew Rissing
15-Feb-11 10:30am
View
Deleted
I don't follow what you're trying to say. Can you complete your thought?
Andrew Rissing
3-Feb-11 9:53am
View
Deleted
I feel like there's a joke somewhere in this title.. :D Good stuff.
Andrew Rissing
18-Jan-11 11:09am
View
Deleted
I edited the above for grammar/readability and redid the summary because it was unclear.
Andrew Rissing
23-Nov-10 15:11pm
View
Deleted
You might want to look at the String.Trim, String.TrimStart, and String.TrimEnd to align it to the way that behaves. For instance, use char.IsWhiteSpace, rather than just checking against a space.
Andrew Rissing
29-Oct-10 10:08am
View
Deleted
I personally like using Stopwatch over DateTime, but that'll work as well. Including the time to retrieve the columns, I get only about a 2x speed improvement using DataColumns. Not as fast as you got, but still significantly faster.
Andrew Rissing
27-Oct-10 12:05pm
View
Hm...mine shows the provider for SQL CE 3.5. Perhaps, you need to reinstall SQL CE?
Andrew Rissing
18-Aug-10 9:54am
View
Are you basically trying to encrypt or 'salt' your strings? If that's the case, I'd recommend searching Google for that.
Andrew Rissing
18-Aug-10 9:50am
View
Be sure to use 'pre' tags for long blocks of code, 'code' tags are used only for inline references to classes/methods/etc.
Andrew Rissing
12-Aug-10 10:53am
View
I'm not aware of enum support for MS SQL, but other DB's may have it.
Andrew Rissing
19-Jul-10 17:12pm
View
Updated answer above...
Andrew Rissing
19-Jul-10 14:47pm
View
You could go a few routes. One would be to use the ThreadPool to kick off a new task each time (plus a little logic to make sure you're not spawning off more than one at a time). This would ultimately be the better if you're wanting to get away from doing a Thread.Sleep.
Another would be to use an object like the ManualResetEvent to wait for a signal from the event that adds to the list. But the ManualResetEvent will essentially do a Thread.Sleep internally...
Andrew Rissing
11-Jul-10 11:04am
View
I can't really help you here with that. It really depends on what exactly you're wanting to do with the data. The best advice I can give is to google around for "VB.NET DataTable" and go from there.
Andrew Rissing
8-Jul-10 10:42am
View
Deleted
You realize your @Command variable is too small for your 500 character @Path input. Plus, based on your ISNULL replacement, @Path can never be null.
Andrew Rissing
8-Jul-10 9:49am
View
Reason for my vote of 2
Lack of information on what you need and this can easily be googled.
Andrew Rissing
8-Jul-10 9:46am
View
Reason for my vote of 1
Repost...
Andrew Rissing
7-Jul-10 17:53pm
View
The path of the file is the index to lookup the value in the dictionary. The BitConverter should be doing exactly what you were doing in code. The Read method returns 0 when it cannot read any more data. The 2 is because you're reading two bytes out.
Andrew Rissing
7-Jul-10 13:18pm
View
Reason for my vote of 1
Not asking a question.
Andrew Rissing
30-Jun-10 13:53pm
View
Deleted
I also just steer clear of sp_executesql, unless its absolutely necessary. In this case, you can avoid it.
Andrew Rissing
30-Jun-10 13:47pm
View
Deleted
Oh, I wasn't saying you could get around the exists check, you can't. I'll post an alternate with what I'm saying....
Andrew Rissing
30-Jun-10 10:06am
View
Deleted
Out of curiousity, why not just drop the function at the start and then create it, rather than alter? Using drop/create, you don't have to worry about the signature of the function matching up as much. Plus, I've read somewhere that using a single SELECT (with multiple assignments in it) over multiple SET's is actually faster. In cases where there is just one assignment, SET wins out. I wonder if that might improve the speed of this function a little bit.
Andrew Rissing
29-Jun-10 17:54pm
View
Deleted
Don't use 'throw ex', but rather 'throw'. If you use 'throw ex', you clear out all stack trace information as if you created a totally new exception.
Andrew Rissing
29-Jun-10 17:53pm
View
Reason for my vote of 2
Using 'throw ex' is not the correct way to rethrow an exception, it clears out all stack trace information.
Andrew Rissing
29-Jun-10 17:52pm
View
Reason for my vote of 5
Correct usage of 'throw'.
Andrew Rissing
29-Jun-10 9:38am
View
Deleted
Yeah, I'm not a big fan of "if (a == true)", but at least it gets you around having to declare a variable just to use it to check a return variable.
Andrew Rissing
22-Jun-10 20:59pm
View
Reason for my vote of 2
Google first, found at least three good hits in the first try.
Andrew Rissing
22-Jun-10 20:58pm
View
http://www.google.com/search?hl=en&q=blowfish+C%23
Andrew Rissing
11-Jun-10 15:19pm
View
I've updated my answer above...btw, read up on how escaped names are used here: http://msdn.microsoft.com/en-us/library/ksh7h19t(VS.90).aspx.
Andrew Rissing
9-Jun-10 13:59pm
View
If you don't have .NET 3.5, you can also use Dictionary<string, object=""> and just set the value to null in all cases. As an alternative to HashSet.
Andrew Rissing
9-Jun-10 13:58pm
View
The check for the predicate is O(n), but the sort is at least O(n*Ln(n)). So, you can only claim O(n*Ln(n)) for speed.
Andrew Rissing
8-Jun-10 14:09pm
View
This error sounds familiar. I believe it is because you're not resizing your device upon the window its being displayed in being resized. I don't know if it'll help, but you can check out my AViD project. It might help you to play with some working DirectX .NET code to figure out how to get your code working.
http://www.codeproject.com/KB/directx/AViD.aspx
Andrew Rissing
7-Jun-10 14:46pm
View
Do some searching online, there are tutorials out there for what you're looking for. Such as: http://dotnetperls.com/sqlce-database-use
Andrew Rissing
4-Jun-10 10:24am
View
Reason for my vote of 2
You are not solving the original intent of your own question...?!? Furthermore, you're not doing it in a performance friendly way.
Andrew Rissing
4-Jun-10 10:23am
View
Why are you posting an answer to your own question, especially so quickly after you've posted it?
Andrew Rissing
1-Jun-10 20:05pm
View
Just a side comment, if "myID" is a string. Use a SQL parameter, rather than just concatenating the string directly yourself, otherwise you open yourself up for SQL injection.
Andrew Rissing
1-Jun-10 20:02pm
View
You can just do "IF EXISTS (SELECT 1 FROM SomeTable WHERE ...) THEN BEGIN <update> END ELSE BEGIN <insert> END"
You don't need to store the value of the EXISTS, just use an "IF" to control the logic flow.
Andrew Rissing
1-Jun-10 18:02pm
View
No problem. I understand where you were coming from.
Andrew Rissing
1-Jun-10 16:19pm
View
While the above query may be correct, it will execute the query for each row in the table, which would lead to bad performance.
Andrew Rissing
28-May-10 11:55am
View
By the way, since you're working in Silverlight, you might want to look at the tip regardless as it deals with some issues Silverlight has with attached dependency properties.
Andrew Rissing
27-May-10 18:04pm
View
Reason for my vote of 1
Repost. I already gave you an answer in the prior post as well.
Show More