|
Nevermind. The javascript is actually loading, it's some other problem.
|
|
|
|
|
Hi, i wanna allocate memory for some data but i dont know how.
With C it loks like
struct MyStruct
{
int number;
string Name;
struct *Next;
}
But i dont know how do that in C#
so could some one help me.
??
thx
|
|
|
|
|
In C# you don't allocate blocks of memory directly. The common language runtime that runs your code handles memory allocation and memory cleanup automatically for you. So instead of malloc, you allocate objects using the new keyword.
MyFoo obj = new MyFoo();
If you're absolutely certain that you need to allocate a block of memory (the only real scenario for this would be interoping with native code), then you can use System.Runtime.InteropServices.Marshal.AllocHGlobal or some of the other interop classes inside the InteropServices namespace.
Does that answer your question?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
but how can i point to the next instance of myFoo.
So if i have to creat 3 data.
i explain, the pointer first points to the beginning of my struct
so i wanna write some think like
first->Next=Second; and so on Seond->Next=Third.
So!!
-- modified at 12:49 Monday 8th May, 2006
|
|
|
|
|
Oh, so you're trying to do a linked list. I see.
You can do that like so:
class MyClass
{
public MyClass Next;
}
MyClass instance1 = new MyClass();
instance1.Next = new MyClass();
instance1.Next.Next = new MyClass();
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
|
ok i ll; try to do it
but one other rquestion,
how cans i store the other data which are int Numer and string name;
does it look like
class Myclass
{
int number;
string name;
public Myclass Next;
}
|
|
|
|
|
torNAdE wrote:
does it look like
class Myclass
{
int number;
string name;
public Myclass Next;
}
Yes.
As a general recommendation, class fields should be private. If you need to access them outside of the class, use a property:
class MyClass
{
private int number;
public int TheNumber
{
get
{
return number;
}
}
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
thank you verry much.
it was helpfull
|
|
|
|
|
I have solution with almost 100 projects. I have one startup project. Everytime if there is any changes in one of the projects i am pressing F5 to build all the projects, which is taking about 30-40 mins. And i don't have provision to uncheck the Build check box in configuration manager of solution, its locked.
Is there any way i can test and debug just the changes made. I tried Attach to process. From bin folder i executed the exe of startup project and try to attach one of the changed projects from solution (which is other than start-up), sometimes it is attaching and sometimes not. Even if it attaches i am unable to debug the changes made.
I am using Framework 1.1
Any help, Very urgent
Thanks
Santosh
|
|
|
|
|
I believe Visual Studio will rebuild any projects that have dependencies on the project you've just modified. So if you modify A, yet B and C depend on A, B and C will be rebuilt as well.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Thats what, i don't want any dependent projects to re-built as almost 50% of the projects are dependent on which i have changed. (help really urgent)
santosh
|
|
|
|
|
But then you're running dirty code: if projects B and C depend on A, and A has been changed, then B and C have to be rebuilt otherwise they could be referecing functions, properties, and variables in A that no longer exist or may have changed.
I recommend asking this question in the Visual Studio forum or in the MSDN Visual Studio forum for a better answer though; I'm not sure if you can tell VS to not rebuild a project even if it is dependent on a modified project.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Try enabling incremental compilation in each and every project (all 100 )
|
|
|
|
|
My app creates a data array that quite happily serializes to disk from a control. If I run another part of the app that generates a data array (I'm assuming correctly as I have no evidence that its not) from a MainForm toolbar, and try to serialize (using Stream and BinaryFormatter) from the same control above, I get an exception that complains that the MainForm (derived from Form) is not marked as Serializable. Changing it to Serializable does not help, and it feels like a band-aid fix anyway.
I believe this message is a symptom of the problem, which I suspect is a section of one of my classes that should have the [NonSerialized] attribute. I have not been able to locate this as yet.
Can anyone offer suggestions what what would cause this?
Stewart DIBBS
|
|
|
|
|
Do you need to serialize your main form? If not, don't serialize it. Whatever object you're trying to serialize, make sure it doesn't contain a reference to the main form, otherwise it will try to serialize it. If it is referencing the main form for a good reason, then add the NonSerializedAttribute to it.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
OK, I see my problem: the serializable class exports an event. The first pass through does not subscribe to the event and serialization works OK, but the second pass does subscribe to the event and the handler is in the mainform code. Hence the seriealization exception I get.
So I have to move the event out of the serialization class. Wasn't happy with the code anyway.
Stewart DIBBS
|
|
|
|
|
I am using MethodInfo.Invoke() to invoke a method that has a ref keyword on a value type in it's parameter list. Example:
MyMethod(int p1, ref int p2)
However there does not seem to be a way to to tell invoke to pass parameter 2 by reference.
I tried to use ParameterModifier. But it has work just with COM interop.
Please help, I am getting an error because it is trying to pass by value instead of pass by reference.
King Regards,
XironiX
[ _ Always there is another way _ ]
-- modified at 11:48 Monday 8th May, 2006
|
|
|
|
|
int param1 = 5;
int param2 = 10;
object[] arguments = { param1, param2 };
theMethod.Invoke(arguments);
param2 = (int)arguments[1];
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Dear Judah,
Thanx for your instant reply.I have another problem with pass-by-ref concept.I have two overloaded methods with the following signatures :
public int MyMethod(ref int intParam)
{
intParam += 100;
return Math.Sin(intParam);
}
public int MyMethod(int intParam)
{
intParam += 100;
return Math.Sin(intParam);
}
When I use typeof(MyClass).GetMethod("MyMethod"); ,System.Reflection.AmbiguousMatchException is throw !!
If I use
typeof(MyClass).GetMethod("MyMethod",new Type [] {typeof(int)});
The second overloaded method with the value parameter invokes.
How can I force the CLR to run the first method and pass the parameter to it by reference ?
Regards,
Xironix
[ _ Always there is another way _ ]
-- modified at 3:13 Tuesday 9th May, 2006
|
|
|
|
|
I'm opening the port as a file by pinvoking several win32 calls similar to the Mc++ implementation below. The problem is that each write causes a .1s stall in my app. I'm only writing 4bytes max at a time, and the delay's remained constant from 2400-19200 baud so actually stuffing the bytes into the uart buffer doesn't appear to be the source of my problem.
http://www.codeproject.com/managedcpp/howtocomport.asp
|
|
|
|
|
|
Ok, did an ~20s trial run.
Slowest lines of code were two where I called CSerialPort.Write(...) ~8s net. and the actual write to the stream in Write.
Slowest methods were:
Forms.UnsafeNativeMethods.WaitMessage() 18s
System.Threading.WaitHandle.WaitOne() 8s
UnsafeNativeMethods.* isn't listed in MSDN help.
Honestly, I don't see that I'm any closer to a resolution.
public void Write(byte[] buf)
{
try
{
m_MyStreamWriter.Write(buf);
m_MyStreamWriter.Flush();
}
catch (Exception e )
{
Console.WriteLine(e.ToString());
}
}
|
|
|
|
|
What I think I need is a way to do the write asyncronously, although that potentially opens up a whole new can of worms with multiple writes piling up over top of each other. Agregating multiple messages and sending them in a single chunk would be another option but I don't currently have access to the blackbox I'm interfacing against, nor do I have specs on its uart or how frequently it checks the buffer.
-- modified at 15:23 Monday 8th May, 2006
Something else that's occured to me, could my not having a null modem hooked up be causing the delay with windows trying and failing to send before giving up?
|
|
|
|
|
Hi PrjectCode Team Thank You For Your Successfull Site That Help Many Developers And Beginners To Develop Their Projects Really I'd like To Ask A Question That Question Is:
How Can I Load The SQL Server DataBases Into A Combo Box Using The ADO.Net And C# And Their Tables In Another One According To The Database That I'll Choose From The Combobox1 ?
Thank You For All Your Efforts
Night Attack
|
|
|
|