Thanks a lot!!!
Erich Ledesma
Posts
-
Article reposting -
Article repostingHello: Can I repost one of my articles in my blog? I'm never completely clear about the legal stuffs. Can I do it the other way around? Thanks
-
JS GraphsI want to put some nice looking graphs in my articles. I already do this on my blog using a js chart library. I know I could use images, but anyways: Is there a library I can use in CP? Is Javascripting allowed?
-
There is something wrong with article voting.Very nice!!! Thanx again mate!!
-
There is something wrong with article voting.I didn't know that. Thanx!!!
-
There is something wrong with article voting.I've noticed one of my articles has either the voting distribution wrong or the rating calculation. My case: An IoC Container in 15 min[^] It says 17 Fives and 3 Fours, that would be a rating of 4.85. Currently a 4.77 is shown. Actually it was 4.77 some days ago, it seemed weird to me, but paid no attention, but today I received a new vote, and the number didn't change.
-
How to combine byte array with sql commandIf you try to inline the array into a string C# compiler will create a
ToString()
call, that's why you're getting a'System.Bytes'
instead of array values. I think you should try to useSqlCommand
parameters instead.SqlCommand cmd = new SqlCommand("Update table1 SET col1=@ByteArray where colid=1", conn) ;
cmd.Parameters.Add("@ByteArray", <Correct Column Type>).Value = byteData;
cmd.ExecuteNonQuery() ;
Almost the same as the image example.... Greettings.
-
.net Language InteroperabilityThere're some very big issues involved here. If your VC++ project produces an exe, it is either a Windows or Console application project. So look bellow. This would work with VS2008, I don't remember how to do it using older versions. 1.- [Easiest] Is the VC++ project a managed project? Go to project properties and take a look under "Common Properties", if this tab works. Allows you to change "Targeted Framework", add references or so. It is a managed project. Solution: Just changed your project output type: Go to "Configuration Properties" > "General" > "Configuration Type" and change it to "Dynamic Library (.dll)". And just try placing the reference in your web.config, it should work. Down side. Global funcions and not managed types are not going to work for you ASP.NET site. All types you'd like to use must be marked as "__gc" or "__value". Take a look to this MSDN link > ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vclang/html/63b1e7ab-d1c8-4582-aa89-21bfddf694a9.htm 2.- [Hardest] Your project is a native one. Solution: First, change the project type, same as above (not mandatory, exe also can export functions). You'll have to make sure you're exporting the funcions you'd like to use from managed code. To see exported functions use "dumpbin.exe /EXPORTS " from VS command prompt. Then you'll have to create a "wrapper" managed library to access to unmanaged, see this one to use native functions from managed code > ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_mscorlib/html/36830e35-7f2e-b1fa-87ca-144346051059.htm . Down side, most web hostings won't allow you to access to native code, or at lest no more than .NET native libraries or Windows API. Hope it'll help
-
Boxing and UnBoxing in C#?Boxing is copying a value type (C# struct) to a reference object in the heap. Unboxing is copying a boxed object in the heap back to the stack. Not just primitive value types: struct S : ISomeInterface { ... } // boxing S s1 = new S() ; object x = s1 ; // S instance is created on the stack, then copied to the heap. ISomeInterface is = s1 ; // This is also boxing ... S s = (S)x ; // This is unboxing, for unboxing you must use the cast syntax. Value types are not always placed on the stack, they are inline into it's container. They might be already on the heap, for instance if they are array elements. S[] a = ... a[i] = (S)x ; Boxed value is copied from the heap to the stack and then copied into a[i].
-
Bool expression??Great point. Never thought of it that way. But it wasn't a sennior programmer making things clearer, nor a junnior one making misstakes. It's just some guy who has been programming for a while and I guess has no clue how boolean expressions work. It's started on C# by the way. Original code
x => if (SomeBoolMeth(x) == true) return true; return false ;
If you were a professor and find this in some test, not from a basic course, what would you do?? Again: Great point!!
-
Bool expression??I found this code somewhere:
...
if (x == true)
return true ;
else
return false ;Actual code was the body of a C# 3 lambda expression. Anyway, horrible.