|
1 - it contains the bits of the image
2 - probably because 32 bits is a waste of time and < 24 is hard to process
3 - each image in memory has an area at the end of each scanline which does not contain pixels and should not be accessed.
4 - because you can't use pointers in C# outside an unsafe block
This looks like it came from my image processing article, didn't I explain all of this there ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
minimilist question
minimilist answer [^]
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
With the ToArray() method
Seriously, your question makes no sense, what is in the struct, that it makes sense to turn it into an array ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi...
I am newbie in c#, please help me on clr trigger.
I have done a clr trigger and everytime i debug my c# code,an error occured on this part
AIClass.AICheck.checkUserRole();
The error description is like this :->
InvalidOperationException was Unhandled
The requested operation requires a SqlClr context, which is only available when running in the Sql Server process.
I dont know what to do...
And I cannot create a trigger inside Sql Server Express Edition 2005. I did like this:->
create trigger tgAI
on AIEvent
for insert
as
external name
AIAssembly.AIClass.userRoleCheck
and the error appeared:-> Msg 6505, Level 16, State 1, Procedure tgAI, Line 1
Could not find Type 'AIClass' in assembly 'AIClass'.
my code in c# is like this (will be called in the main class in console App.):->
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data;
using System.Data.SqlClient;
namespace AIClass
{
public class AICheck
{
//[SqlTrigger(Event = "FOR INSERT", Name = "AI_tg", Target = "AIEvent")]
public static void checkUserRole()
{
SqlTriggerContext tgContext = SqlContext.TriggerContext;
//SqlConnection conn = new SqlConnection("Data Source=DIMENSION3000\\SQLEXPRESS; Initial Catalog=AITania; User Id=sa; Password=123456");
using (SqlConnection conn = new SqlConnection("context connection=true"))
conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlDataReader reader;
string msg = "";
if (tgContext.TriggerAction == TriggerAction.Insert)
{
//SqlCommand sqlComm = new SqlCommand();
//SqlPipe sqlPipe = SqlContext.Pipe;
cmd.CommandText = "SELECT * FROM INSERTED";
reader = cmd.ExecuteReader();
//sqlComm.Connection = conn;
//sqlComm.CommandText = "SELECT * FROM INSERTED";
//for (int x = 0; x < tgContext.ColumnCount; ++x)
//{
// msg += string.Format("Column {0} {1} been updated{2}", x, (tgContext.IsUpdatedColumn(x) ? "has" : "has not"), Environment.NewLine);
//}
for (int i = 0; i < reader.FieldCount;i++ )
{
msg = msg + reader.GetName(i) + ":" + (string)reader[i] + " ";
}
}conn.Close();
}
}
}
Please help me..
thanks..
-jack-
|
|
|
|
|
You cant use that code outside the SQL environment, you will have to specify a proper SQL connection string.
|
|
|
|
|
hi leppie..
hem..thanks for the suggestion...but still blur..
so..how do i supposed set the connection string properly..
whenever i debug my project..it came out like this...
The Error:
AIClass.AICheck.checkUserRole();
--> invalidOperationException was unhandled
--> The requested operation requires a SqlClr context, which is only available when running in the Sql Server process.
i have search at msdn help online but still cannot find the answer..
please help me...
thanks a lot
Jac
|
|
|
|
|
I'm very new to .NET 2.0 even I have experiences in .NET 1.1.
It would be really great if anyone can give me three or more real scenarios where anonymous methods should be used or where can't be done without those kinda methods.
The main advantages of using anonymous methods that I know so far is that it saves the time of typing.
Thanks in advance.
|
|
|
|
|
The main reason I would use them is
a - where I define a timer and want to define what it does inline
b - where the method I create relies on the state of variables in the method it was created in
I don't use them much.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I've use them on collections a lot, for sorting, extracting etc, but how would you use one with a timer? The concept sounds neat.....go on......post a couple of lines to explain..
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
I just mean that when I create a timer, I'll often make the tick event fire an anonymous method. That way the timer is defined, and what it does is defined, in the same place.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thats slick - didn't know you could do that. I have loads of events firing off to do 1 or 2 lines of code. Humour me here...is the following correct...
System.Timers.Timer t = new System.Timers.Timer();
t.Interval = 100;
t.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e) { Console.Write("."); };
t.Start();
while (true)
{
System.Threading.Thread.Sleep(1000);
}
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Exactly. And, your timer method will be in the scope of the method that created it, which is sometimes very handy indeed.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
One great advantage of anonymous methods is that it can access local variables within the regular method scope. For example:
List<int> numbers = new List<int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
List<int> primeNumbers = new List<int>(new int[] { 2, 3, 5, 7, });
List<int> nonPrimeNumbers = numbers.FindAll(delegate(int i) { return !primeNumbers.Contains(i); });
If I had used a classic delagate, primeNumbers wouldn't be accessible.
|
|
|
|
|
ack thats so useful and I cant believe I didn't think of it!
There are loads of places where I have Find delegates for the List<> object and Ive had to store a member variable with a parameter that I had accessible in the calling method!
|
|
|
|
|
Thanks for pointing this out!
Kevin
|
|
|
|
|
Thanks a lot for your answer. Christian Graus,Malcolm Smart and szukuro.
The way I understand is that things that can be done with anonymous method can also be done with delegate. There is no particular case that has to be used the anonymous method.
Michael Sync wrote: scenarios where can't be done without anonymous methods.
there is no such a case. isn't it?
The advantages of using anonymous methods is that we can organize the code and it can save the time of typing.
So, the usage of anonymous methods is not vital. it's just extra thing that help the developer to write the code quickly (more productivity. )
That's all.
Is there anything can be added more??
|
|
|
|
|
Michael Sync wrote: The way I understand is that things that can be done with anonymous method can also be done with delegate. There is no particular case that has to be used the anonymous method.
Depends on how you view it. As I pointed out in my example, a regular delegate couldn't have accessed the local variable, so it could not have been done that way. Then again you can overcome this by simply declaring a class member for example so the regular delegate can access it. So yes, one way or another anything can be achieved with regular delegates as with their anonymous counterparts, however there are scenarios where one should be favored over the other.
Also a side note, in C# 3.0 you can use lamdba expressions, which are much shorter then anonymous methods (but are more or less the same thing, though the former can be built in run-time using expression trees). So you can write code like:
List<int> nonPrimeNumbers = numbers.FindAll(i => primeNumbers.Contains(i)); Pretty neat, don't you think?
|
|
|
|
|
oh. wow.. ya... i totally agreed with you.. Thanks a lot.. szukuro..
|
|
|
|
|
1. Closures
2. Closures
3. Closures
|
|
|
|
|
hi there,
i have a problem in array that is i define an array of string in general declaration
string[] mlines;
and in load event i assing a value to it like this
mlines[0] = "xyz";
but when i run application it gives error
"Object reference not set to an instance of an object."
its giving error because it default value is null...
can somebody tell how to solve it.....;P
Becoming Programmer...
|
|
|
|
|
string[] mlines = new string[3];
mlines[0] = "xyz";
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
I suggest you read a basic C# text, you cannot create any reference type without the 'new' keyword.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
The StringCollection would be the dynamic way!
System.Collections.Specialized.StringCollection yourStringCollection = new System.Collections.Specialized.StringCollection();
yourStringCollection.Add("addedText");
All the best,
Martin
|
|
|
|
|
xmen_xwk wrote: string[] mlines;
where is the "new" keyword?
try :
string [] mlines = new string [3];
Regards,
Tomi
|
|
|
|