|
If you don't mind spending the money you can use www.copyminder.com but if I were you I would request the names of the 10 computers and their IP Addresses that the application will be running on this way you can check if a computer is one of these 10 and if so allow the application to run otherwise not.
I know it's messy and probably not the best idea, but it will work.
Freedom is the right to say that 2+2=5 if this is so everything else will follow.
|
|
|
|
|
Hi,
Which one gives better performance, checking a string against null & empty.
string s = "something";
for(int i=0; i<100; i++) {
if(s != null) {
if(s.Length > 0) {
}
}
}
or
for(int i=0; i<100; i++) {
if(!String.IsNullOrEmpty(s)) {
}
}
plz help,
nas
|
|
|
|
|
put it in a loop that will run a few hundred thousand times and use the System.Diagnostics.StopWatch[^].
It's a good idea to get used to testing things like this yourself ... it's quicker than asking on here, more reliable and you have more chance of getting an answer with some of the more obscure stuff (not that IsNullOrEmpty is obsucre).
|
|
|
|
|
But he doesn't want to do any of the work himself. He needs someone to do his homework form him.
|
|
|
|
|
Or use Reflector to check what String.isNullOrEmpty does:
public static bool IsNullOrEmpty(string value)
{
if (value != null)
{
return (value.Length == 0);
}
return true;
}
IsNullOrEmpty is therefore just a bit slower because there is a strack frame more present (for calling the method). But compared to the time you are using in writing that every time, I'd use IsNullOrEmpty
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Seriously, for the additional fractions of a microsecond that IsNullOrEmpty takes I wouldn't worry about it.
|
|
|
|
|
Won't .Length check for null again anyway? If so, you're checking for null twice.
I'd just use IsNullOrEmpty figuring Microsoft wouldn't steer me wrong.
|
|
|
|
|
PIEBALDconsult wrote: Won't .Length check for null again anyway? If so, you're checking for null twice.
.Length cannot operate on null so it will throw an exception.
|
|
|
|
|
::Smacking forehead with heel of hand::
|
|
|
|
|
i know the meaning of sealed classes.My Question is when should i use the sealed classes.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Well the meaning of it shows when it should be used ... it stops anyone inheriting your class, so it should be used when you don't want someone to inherit your class :P
Two examples of this in the Base Class Libraries are the List and String Builder. These 2 are sealed as they are "high performance" classes which microsoft don't want anyone inheriting and then messing around with the internals and messing them up (well thats the official line anyway).
|
|
|
|
|
I KNOW IT SHOULD BE USED TO DEPRIVE OF SOME INHERITING MY CLASSES.
BUT ONE CAN ACCESS THE MEMBER FUNCTIONS AND MEMBER VARIABLES BY INSTANTIATING THE CLASS.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Sure, you can access the members of a sealed class. sealed is not an access modifier like private, protected, public, internal, protected internal.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Please - no shouting. Your keyboard has both upper and lower case.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yes. And your point was?
Sealed doesn't mean it can't be instantiated - that's what abstract means. It just means that it can't be inherited.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hardly ever; it's rude. I very much dislike running up against sealed classes and having to find a less-elegant solution than inheritance.
|
|
|
|
|
PIEBALDconsult wrote: I very much dislike running up against sealed classes and having to find a less-elegant solution than inheritance.
I agree on this point, but there are also cases where sealed classes are useful. The most common use are for performance sensitive classes, utility helper classes (which can now use the static keyword, which also makes them sealed ), and value types (all enums are sealed ).
With the upcoming .NET 3.5 release, not being able to inherit a sealed class becomes less of an issue due to extension methods.
|
|
|
|
|
Hi,
Kindly help me that, How can I insert a character between any string value?
Example: string value is : ABC/DEF/GHI
after inserting..........: ABC-DEF-GHI
Thank you in advance
|
|
|
|
|
Use the Insert method of the string class.
However, in your example you replaced a character with another one. In this case use the Replace method.
|
|
|
|
|
use Replace function
for example : string str="ABC/DEF/GHI";
str=str.replace('/','-')
|
|
|
|
|
When my post build event runs I get this message
Error 1 The command "copy bin\Debug\plugin.dll C:\Program Files\SomeApp\Plugins" exited with code 1.
If i open an elevated commandline at the project folder I can execute the command perfectly well.
I'm running VS2005 as admin and i need to copy my plugin to the apps plugins folder inorder to run it. This isn't my app, it's an app I'm integrating with so I can't change the location of the plug-ins folder.
Any Ideas?
Thanks
Russell
|
|
|
|
|
Doesn't really have to do anything with C#, does it?
Anyway, you should start reading about UAC under Vista. You'll learn (among other things) that even running an application while logged in as admin won't give you the same access rights XP gave you.
You could try running VS with elevated rights or turn off UAC completely.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
i guess it's got very little to do with c#, it would probably be better in the Vista forum but i thought it was a problem that other c# developers might be running up against so i posted it here.
I am running the VS IDE as Administrator rather than running it when logged in as administrator. I've been fighting battles with UAC for a while now and I thought I had a handle on it but this seems really confusing, i'm not even 100% sure if it is an issue with UAC.
Russell
|
|
|
|
|
Experts,
I want to implement some COM interfaces in C#, and these interface will be called by a DLL written by ATL. The COM interface definations are :
__interface IDataRelation : IUnknown
{
...
HRESULT GetData(
[in] long Item,
[in] REFIID riid,
[out, iid_is(riid), retval] void **Data);
}
__interface IArray : IUnknown
{
...
}
__interface INumber : IArray
{
....
HRESULT GetUnits([out, retval] BSTR *Units);
}
__interface IDoubleNumber : INumber
{
...
}
The native code will call IDataRelation.GetData() to get the pointer of INumber to get the data unit.
I rewrite the interfaces in C#
[ComImport, Guid(XXX), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IArray {...}
[ComImport, Guid(XXX), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface INumber : IArray
{
...
[Return : MarshalAs(UnmanagedType.BSTR)]
string GetUnit();
}
[ComImport, Guid(XXX), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDoubleNumber : INumber {...}
[ComImport, Guid(XXX), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDataRelation
{
[Return : MarshalAs(UnmanagedType.Interface)]
object GetData(
[In, MarshalAs(UnmanagedType.I4)]
int Item,
[In, MarshalAs(UnmanagedType.Struct)]
ref Guid riid);
}
Then I construct two classes to implement these interfaces.
public class ArrayBase : IArray, INumber, IDoubleNumber
{
string INumber.GetUnit()
{
return m_Unit;
}
}
public class Data : ArrayBase, IDataRelatin
{
...
public object GetData(int Item, ref Guid riid);
{
return this;
}
}
Every thing seems fine, IDataRelation can be retrived in the C++ code.
CComQIPtr<idatarelation> pRelation = GetDataRelation(...); //Get data relation
if(pRelation != NULL)
{
CComQIPtr<inumber> testNumber;
pRelation->GetData(0, UUIDOF(INumber), reinterpret_cast<void**>( &testNumber ));
if(testNumber != NULL)
{
CComBSTR m_DataUnit;
testNumber->GetUnit(&m_DataUnit); //Error !!!
}
}
When I call GetUnit, a strange error occured, see the following detail :
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
The ATL DLL is used to display a chart. I use it in my C# project. The above interfaces are its
data source interface. I just want to implement these interfaces to supply my own data source for
it. My project is not a COM server and not COM visible.
The ATL DLL is written years ago, but only used by other C++ projects and have no problem, I can't change anything.
I haved searched for the above error solution, but got nothing.
Now, Any idea?
-- modified at 5:01 Thursday 6th September, 2007
c++ : my dream
|
|
|
|
|
Hy
Can anybody tell me how can I set the position of the keyboard (not mouse) cursor in a RichTextBox.
thanks
|
|
|
|