|
Maybe there is some other solution ....
|
|
|
|
|
Can anyone tell me how to escape the dollar signs in a code snippet?
As a first attempt at writing a code snippet I've hit a bit of a snag. It seems that, what I thought would be a fairly simple first attempt, isn't.
I attempted to create a snippet so I could insert a block of code that the version control system could use to add its log message to the source file.
i.e.
#region Source Control File Version Log
#endregion
However, it seems in my haste I didn't realise that the $blah$ is supposed to be expanded out to something else when the snippet is inserted. When I insert the snippet in to the code a blank appears where $History: $ appears.
I've had a look around and I can't see anything about escaping the dollar signs (so I'm obviously looking in the wrong places).
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
|
|
|
|
|
|
Hello,
Any ones help would be greatly appreciated on this.
We have a webservice that invokes a dll and a c# .Net windows application. Is there anyway thay would enable the Dll invoked by the webservice to invoke a function in the windows application???? given that the application is runing of course.
And another question is:
Is there a way for a windows application written in C# to call a function in a running windows service??? like a function that will cause the windows service to update itself???
any help will be greatly appreciated
thanx
|
|
|
|
|
hi,
how can i find a given number using binary search?
thank you.
arun
|
|
|
|
|
Binary search in what? In an array, in a file, in any stream?
_____________________________________________________________________________
I don't expect too much, all I want is your vote for Halbsichtigkeit.
|
|
|
|
|
|
I rated this question as a '1'. I highly recommend you read Chris' sticky post on 'How to get your questions answered'. First, your subject does not provide any input for what area you are looking for help on. Second, your question is so generic that no one could possibly answer your question!!! Finally, your question does not indicate what you have tried.
CodeProject is not here to do your job, to do your work, to do your research for you. CodeProject is a group of developers that help other developers with new features, articles with plenty of how-to's, and help to a developer who is trying to do something and getting stuck.
As to your question, I googled Binary Search and got not only a definition but also a code sample. Then looking at the code sample it looks like it could be an IComparer implementation that may easily fit into a custom collection definition. So I would suggest you begin working like a developer.
|
|
|
|
|
Hello, I have a function written in C++ that return a wchar_t*. I don't know how can I receive the data in a C# program.
I can I have 2 type of my C++ function:
1) void GetDestFromSource(char *pSourceString, wchar_t *pDestinationString);
2)wchar_t *GetDestFromSource(char *pSourceString);
In my C# program I try some kind of prototype for the first C++ function but they don't work:
[DllImport("MyDll.dll")]
1 Attempt) public static extern void GetDestFromSource(string pSourceString, string pDestinationString);
2 Attempt) public static extern void GetDestFromSource(string pSourceString, out string pDestinationString);
3 Attempt) public static extern void GetDestFromSource(string pSourceString, StringBuilder pDestinationString);
4 Attempt) public static extern void GetDestFromSource(string pSourceString, out StringBuilder pDestinationString);
In my C# program I try some kind of prototype for the second C++ function but they don't work:
[DllImport("MyDll.dll")]
1 Attempt) public static extern string GetDestFromSource(string pSourceString);
2 Attempt) public static extern StringBuilder GetDestFromSource(string pSourceString);
All the attempts don't work. Can anyone help me? Thank you very much for any answer.
SD3
|
|
|
|
|
I got the following problem I have a class that contains a List<t> member.
I want the users to have access to that list, but only to read the data. So I implemented a property that returns the list.
The list is indeed readonly meaning I can^t add remove or change any references in the list. However I can change the values of the references. Is there anyway I can avoid that?
simple example:
The basics of the wrapper
<br />
class listWrapper<X> where X : class<br />
{<br />
private List<X> myList;<br />
public List<X> TheList <br />
{ <br />
get { return myList.AsReadOnly(); } <br />
}<br />
public listWrapper()<br />
{
<br />
}
For the sake of the example a simple class with a property
<br />
class SomeObject<br />
{<br />
private int aProp;<br />
public int ACertainProp<br />
{<br />
get { return aProp; }<br />
set { aProp = value; }<br />
}<br />
}<br />
And finally a class using the wrapper
<br />
class AnotherClass<br />
{<br />
public void Method()<br />
{<br />
listWrapper<SomeObject> wrapper = new listWrapper<SomeObject>();<br />
<br />
SomeObject anObject = wrapper.TheList[0];<br />
anObject.ACertainProp = 15;
}<br />
}
|
|
|
|
|
You can either make your SomeObject immutable.
eg:
class SomeObject<br />
{<br />
private bool immutable = false;<br />
private int aProp;<br />
public int ACertainProp<br />
{<br />
get { return aProp; }<br />
set { if (!immutable) aProp = value; }
}<br />
<br />
public void MakeImmutable()<br />
{<br />
immutable = true;<br />
}<br />
}
however this might not be what you are looking for? this makes the object immutable for every consumer.
another approach might be to simply clone your objects and fill the list with clones.
the clones wont be readonly (unless also supporting immutable)
this might be useful if your main concern is just to avoid that people change your data.
you could also try making wrappers for your objects, where the wrapper and the SomeObject shares the same interface.
either way, there is no good approach to make an object readonly out of the box, you have to write a bit of code no matter what approach you select.
Id probably go for immutable clones.
foreach (SomeObject obj in realList)<br />
{<br />
SomeObject clone = obj.clone();<br />
clone.MakeImmutable();<br />
resultList.add(clone);<br />
}
//Roger
http://www.puzzleframework.com
[edit]
forgot to say , wrappers have an edge over clones because a wrapper will always reflect the real values of the real objects properties.
a clone will just reflect the values of the properties of the real object when the cloning was done.
|
|
|
|
|
Hi,
We have to save a datetime in the database in format: "yyyyMMddHHmmssff".
For this we can use the ToString method, no problem here.
But I can't find how to set the DateTime object back again when we read out that value from the database.
I've looked into Convert.ToDateTime and TryParse , TryParseExact methods, but somehow I can't find what I'm looking for.
How can you set a DateTime object from a string with that format?
thanks !!
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
There is overload of DateTime.TryParseExact[^] that takes a format string.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
mmm, Must of looked over that one. I'll try it thanks.
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
V. wrote: We have to save a datetime in the database in format: "yyyyMMddHHmmssff".
Why? Can't you store it as a datetime value?
---
b { font-weight: normal; }
|
|
|
|
|
Sure we can, but client specs says otherwise .
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
Hi folks,
I need to convert characters such as: 0xFF, 0xAE, 0x24 into integer or byte.
I tried to strip the 0x and let Convert.Tobyte does the conversion but it didn't work.
Please help.
Thanks
Tony
|
|
|
|
|
There's no standard code for this that performs very well. I wrote this to fix the problem. It uses the ascii table to conver the char value (cast it to an int) of a character. Be sure to pass valid characters to the method, it has no error handling. It's case insensitive, by the way. Hope it helps.
int first = HexToDec((int)yourfirstchar);
int seccond = HexToDec((int)yourseccondchar);
int total = 2 * (byte)(first * 16 + seccond);
private static int CharToHex(int charValue)
{
if (charValue > 64 && charValue < 91)
return charValue - 55;
else
if (charValue > 96)
return charValue - 87;
else
return charValue - 48;
}
|
|
|
|
|
You must remove the "0x" and see this sample:
int i = int.Parse("FF", System.Globalization.NumberStyles.HexNumber);
float f = float.Parse("FF", System.Globalization.NumberStyles.HexNumber);
byte b = byte.Parse("FF", System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
Thank you buddy.
All work except the float.
But it doesn't matter because all I need either the integer or byte.
Thanks again,
tony
|
|
|
|
|
This is my code for changing input from textbox to float value:
Just play with this code.
byte[] tempbyte = new byte[4];
tempbyte[0] = byte.Parse(this.textBox8.Text.Substring(6, 2), NumberStyles.HexNumber);
tempbyte[1] = byte.Parse(this.textBox8.Text.Substring(4, 2), NumberStyles.HexNumber);
tempbyte[2] = byte.Parse(this.textBox8.Text.Substring(2, 2), NumberStyles.HexNumber);
tempbyte[3] = byte.Parse(this.textBox8.Text.Substring(0, 2), NumberStyles.HexNumber);
this.textBox7.Text = BitConverter.ToSingle(tempbyte, 0).ToString("F2");
|
|
|
|
|
Hi guys
I'm writing an application that uses threads to execute some code. But these thread must run until some event happens. When this thread has finished executing and the event to stop it has not occured, the thread must start executing again. Now, how do i make this thread start executing again without starting a new thread?
Thanks
Kulile --- RSA
|
|
|
|
|
Run the thread method in a loop, so that it starts again and again until the event switches a stop/running flag:
private void yourThreadMethod()
{
this.isRunning = true;
while(this.isRunning)
{
doSomething();
}
}
private void sender_eventMethod(object sender, EventArgs aarrrgs)
{
this.isRunning = false;
}
_____________________________________________________________________________
I don't expect too much, all I want is your vote for Halbsichtigkeit.
|
|
|
|
|
if you use pirated software you have to write :
private void sender_eventMethod(object sender, EventArgs YYAAARRRGGS)
:P
|
|
|
|
|
IMO it would be better to use a synchronization object, such as mutex or ManualResetEvent
|
|
|
|