converting values--need help You can't convert a string to hexadecimal. Unless you mean a textual representation of an integer. If you're starting with a textual representation of an integer, just use Int32.TryParse(). Once you have an Int32 value you can simply use int32Value.ToString("X") to convert it to hexadecimal. To convert a string to a byte array, you'll can use the ASCIIEncoding.GetBytes method. For example:
Code Snippet
String text = "1234" ;
Int32 number;
if ( Int32 .TryParse(text, out number))
{
text = number.ToString( "X" );
ASCIIEncoding ascii = new ASCIIEncoding ();
byte [] bytes = ascii.GetBytes(text);
} Tag: Visual C# General Conveting from bmp to pcx file Visual C#
File Monitoring Hi all,
Just wondered how I monitor files in my system(opening, writing and cet.(something like AV)).
I will appricate a sample code.
thanks. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
How to fill an array with different variable types? Hello,
I can't find a good solution for creating and filling an array like filling a table with records where each record has the same structure but has different variable types like each record containing an 'int' and a 'string' and a 'Panel object'
//I used a structure like...
struct stuRecord{
private int i;
private string s;
private Panel pnl;
//constructor
stuRecord('args')(
//store args in privates
)
}
//...and an array of myRecord objects...
stuRecord[] myTable = new stuRecord[12];
//... each filling with a record...
myTable[0] = new stuRecord(123,"test1",myPanelObject1);
myTable[1] = new stuRecord(456,"test2",myPanelObject2);
I also used an ArrayList to store these structure objects but both methods somehow 'dont feel good'...
I feel that there should be a nicer solution.
All tips welcome,
regards,
Henk Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Questions on interfaces Assume "IClass" is an interface and "MyClass" implements it. What's the difference between the following 2:
1) IClass c = new MyClass();
2) MyClass c = new MyClass();
Also what's the purpose of casting to interfaces like this (taken from an app with Spring.NET framework):
ICultureConfigurationManager cultureConfigManager =
(ICultureConfigurationManager)SimpleObjectFactory.getObject( "cultureConfigManager" );
My understanding from the above is that, it creates an instance of ICultureConfig... and then assigns it to some object from the SimpleObjectFactory class which has been casted to the ICultureConfig... interface. Anyway, I don't understand how casting to an interface works and how useful it is.
Finally what's the difference between using the above method to cast to interfaces and using the "as" keyword
Thanks. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
is it possible to have tool windows on autohide without mouse hover? I have all the tool windows I use docked to the edges of Visual Studio 2005. In order to see the code, I have set them to autohide. This is somewhat annoying though, since the only thing required to show them is to hover the mouse over them. Every time i accidently pass the mouse over a docked tab it has to briefly show and then immediately hide again. Is there any way to disable the show docked window on mouse hover feature, and only have autohidden tabs show when I explicitly click on their tab. (Hiding again when i click elsewhere) Tag: Visual C# General Conveting from bmp to pcx file Visual C#
how to write a function to read string (or byte)from right side Well, if you are going to use a for() (as opposed to a foreach()), you might as well use it to your advantage:
public static string ReverseStringWords( string input) { StringBuilder sb = new StringBuilder(input.Length); string [] words = input.Split(' '); for ( int i = words.Length - 1; i >= 0; --i) { sb.Append(word[ i ]); sb.Append(' '); } if (sb.Length > 0) sb.Length --; // remove final space. return sb.ToString(); }
Of course, as I was writting that, I thought of this method:
public static string ReverseStringWords( string input) { string [] words = input.Split(' '); Array>Reverse(words); return String.Join(" ", words); }
Tag: Visual C# General Conveting from bmp to pcx file Visual C#
C# ANY GOOD?? for programs need low level access to HDD?? There's nothing stopping you from PInvoking all the functions you'd need to call in a "lower-level" language like C++. It gets tedious declaring all the DllImports and the structures you might need; for that reason I suggest doing that in C++ and using C++ Interop to make wrappers that can be used by managed code (C++/CLI, C#, VB.Net, etc...). Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Memory Leak You need to take a hard look at your code and see where items are being retained, i.e. references holding on to objects. I recommend you implement a dispose on all objects and verify these two things
Release of all references within the object.
Unsubscribe to any events that have been subscribed to. Failure to do this pins the reference and it will never go out of scope. Also I recommend that you run unit tests on everything behind the Web Service. (The code is broken out in tiers right ) and test the tiers for memory leaks away from the web service. That will make the code more bullet proof and remove the web service as the culprit, or show where the problem is... Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Problem to find an object in hashtable: objects hashcode changes somwhere I got a strange problem while developing a tool for Outlook 2007. I write here as I think that my problem is not Outlook specific. My tool receives several information units from a server. For each unit there is a task item created in Outlook and also an information object that holds some specific information for each unit. both objects (task item (key) and info object (value)) are then stored in a hashtable to ensure a connection between them. also the created task items are displayed in outlook. if the user selects one of the created task items and executes a particular function my goal is to find the selected task item in the hashtable and get the related information object this way. the problem is, that the task item could not be found in the hashtable. I check things out and noticed that, at some point, the hashcode of the selected taskitem changed so that it is different from its origin hashcode in the hashtable task item object. therefore the hashtable.contains function fails I can't explain myself when and WHY this hashcode value changes In the meantime between creating the task item and looking up for it there are no changes made.... I'm using VSTO, Visual Studio 2005 and Outlook 2007 Can you help me Thanks Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Logical Drives ? Peter Ritchie : you can't just get certain logical drives
okay thanx, i expect that.
thanx for every body
this topic is closed Tag: Visual C# General Conveting from bmp to pcx file Visual C#
static void Main(string[] args).........question I am relatively new to c#. My experience so far has been with console apps. I have recently learned that the user input from the keyboard for a console app is of the datatype string. I am trying to figure out the significance of the word string in the following code. I am guessing that it is due to the fact that the keyboard input is a string datatype. I am also guessing that this is telling the compiler the type that will be passed is string.
static void Main( string [] args)
Can anyone confirm or correct me on this.....................................................thanks Tag: Visual C# General Conveting from bmp to pcx file Visual C#
ANTI-REFLECTOR SOURCE Almost the same question. Can I prevent invokation of some private method via reflection from other code Tag: Visual C# General Conveting from bmp to pcx file Visual C#
C# Programming->Structure HI
why we can't initialize the variable inside the structure. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
[Resolved]Accessing data set outside windows service... Hi,
I like to set values outside of a windows service, like in an app.config or xml file, like a filepath or constant value, to avoid recoding, reinstalling the windows service every time values is changed, can you provide codes how to do this
I am looking at ConfigurationManager.OpenExeConfiguration(), but what path will I supply to make it dynamic Tag: Visual C# General Conveting from bmp to pcx file Visual C#
catch statement problem Hello Xelestial,
From your description, I get to know that you got an exception saying "An established connection was aborted by the software in your host machine" in using sockets to communicate with another application. According to my work experince, there are a couple of cases we know of which can cause them as follows:
1. If this error is being reported by your email client or by VPOP3 when downloading and/or sending email, it could be a problem with your antivirus software. Both McAfee VirusScan 8 and Norton Antivirus 2004 have been found to give these errors sometimes, but other virus scanners or versions may also cause these errors. See below for more information.
errors with McAfee VirusScan 8
errors with Norton Antivirus 2004
2.If the 10053 error is reported in the VPOP3 Status Monitor program, then this usually means that the VPOP3 server has stopped for some reason. It may be that it was stopped by someone else, or it may have failed with an application error.
3.The TCP/IP Connection was aborted by Windows. This was possibly due to a data transmission timeout or protocol error. The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.
What I want to suggest you to do is to try to check if you have these issues in your application. If you have any questions when trying my suggestions, please let me know. Thanks.
Citizens on the earth Tag: Visual C# General Conveting from bmp to pcx file Visual C#
what -32767 means ? make a property that tells you if the shift key is pressed or not
Code Block
public bool IsShifted {
get
{
if (GetAsyncKeyState(keys.ShiftKey) <0)
return true;
return false;
} } Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Multiple inheritance scenario That's why we want macros, at least global conditional pieces of code that can be inlined anywhere. You could use Eiffel for .NET, it supports multiple inheritance, but only in Eiffel. Not sure how it interacts with .NET though. But here's another idea: Define (perhaps sealed) classes and "wrap" them inside the classes that supposedly inherit from them (required by the interface): public class Alice { //... } public class Bob : Alice, ICarmine, IDopey { readonly Carmine carmine = new Carmine(); public Carmine Carmine { get { return carmine; } } readonly Dopey dopey = new Carmine();
public Dopey Dopey { get { return dopey ; } } } public interface ICarmine { Carmine Carmine { get ; } // and not set } public interface IDopey { Dopey Dopey { get ; } } public class Carmine { //... } public class Dopey { //... } However it almost completely breaks the inheritance logic... Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Huge String List Can anyone suggest the best Collection Class to store a large list of string variables. A list with an amount over 100,000,000 strings. Ive tried so many ways but my program always slows down and my computer runs out of memory. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
ExtractAssociatedIcon Help!!! Thanks Paul for your replay, the problem is not how to get the icon your class get the icon, the problem how to save that icon to the disk, the .Save function deforme the icon,
Any way thanks a lot for your post :).
Chear. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Show differences See : http://www.codeproject.com/cs/algorithms/diffengine.asp .
Wes
http://www.21concepts.com Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Database Upadate Problem I have created all the required component for data access in windows form (from the walkthrough).
I am able to fetch the data from database table (access database). but after changing the data when I press save button it does not reflect data to my database here is the code I have used in save button click.
private void studentBindingNavigatorSaveItem_Click( object sender, EventArgs e)
{
this .Validate();
this .studentBindingSource.EndEdit();
this .studentTableAdapter.Update( this .studentDataSet.Student);
} Tag: Visual C# General Conveting from bmp to pcx file Visual C#
C#/MSMQ Issue Another piece of information (and this is very weird)...
We created a queue manually, and it worked fine. We then went into the security properties and removed the 'everyone' entry (which was added by default), added administrators/users etc. instead and it stopped working (same symptoms). So then we went back into the security properties, removed the users/administrator entries and put everyone back (with full control) - and it was still broken, even though this was the way it was configured initially.
Now that's weird in itself, but even if the security on the local queue didn't allow my app to read it etc. surely the messages should disappear from the sending queue and never arrive in the local queue The MMC snap-in hasn't been reporting any security errors, and neither has my app. We were logged on as a local admin anyway, so we should have always had permissions.
Anyone got any clues now Tag: Visual C# General Conveting from bmp to pcx file Visual C#
string vs. String / double - Double / etc. If we are talking about C#, not C++ (a little bit unclear since you mentioned pointers in your original post), then saying:
double d; //Double d is the same thing
double d = new double(); //Double d = new Double() is the same thing
does not dictate if the double variable lives on the stack or the heap, it could live on the stack or the heap, it depends in the context of where the variable is used (a common misconception in C# is that value types live on the stack always). For example a double that is a local variable in a function will be created on the stack irregardless of whether you say "double d;" or "double d = new Double()", however a double that is declared as a field in a class, will be on the heap, since the class is a reference type which is declared on the heap, since the double is part of the class its data is also stored in memory on the heap, i.e.
using System;
namespace ConsoleApplication2
{
class Program
{
static void Main( string [] args)
{
Test t = new Test ();
}
}
class Test
{
private double d;
public void Foo()
{
double d1;
double d2 = new double ();
}
}
}
Mark. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
protecting c# program Hi guys
If i have a c# program which i want to operate only on a specipic computer what should i do
someone suggest me to use System.Management inorder to get a unique number from the computer itself
and then check if the number equal to my compter number, but it's seems a little bit easy to break.
thank you
Sorsh ^_^ Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Good Resources on program design?? Thanks TilaGopi,
Very nice resources, they will definitely help me out.
thanks for your help. Tag: Visual C# General Conveting from bmp to pcx file Visual C#
TLB registration isue - how to register TLB with GUID with regtlibv12 or C# solution Hi all,
I have created .NET classes, compiled it as DLL and registered via REGASM. Regasm created TLB file, saying that "TypeLib was registered".. i also created REGfile with regasm and added it to the registry manually, BUT - the TLB specification is in fact NOT registered in the registry.
What is in the registry after using regasm:
HKCR\ CLSID \{GUID}\...
HKCR\ ClassNamespace . CLassName \...
HKCR\ Record \{GUID}\... (Enum declarations..)
with all above the COM interop functions fine. I can create instances of my class from ASP, etc. Thats fine.
But when i try to use <!--- META type="Typelib" uuid="{GUID}" --> (or something like this) - the asp ends up with 0223 error saying, that the TypeLib is not registered.
Actually - after using RegAsm the registry HKCR\TypeLib\{...} contains no typelib declarations specified by my DLL nor TLB.
What is not in the registry after using regasm:
HKCR\ TypeLib \{GUID}\...
So, what did I next was a little detective work - trying figure out how to register TLB properly.
Finally i found regtlibv12 which resides in 2.0 framework directory (%systemroot%\microsoft\framework\v2.0...\). However this "tool" is not documented at all, even has no "help" message at the command line (wtf ).
So - the only thing i am able to do now is to register the TLB file from it's location, with no clue how to set up GUID and..i must even correct the registry path, for it is incomplete.
So..my question is - is this a correct way to register TLB file How do I specify the GUID for the regtlibv12 tool
Or - Am I completly wrong or missing something - than please correct me or tell me, how to register these mysterious TLB sort of things...
Thank you,
JV Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Array.Reverse string [] parts = this .textBox1.Text.Split( new char [] { ' ' });
for ( int i = 0; i < parts.Length; ++i)
{
char [] characters = parts .ToCharArray();
Array .Reverse(characters);
parts = new string (characters);
}
string result = String .Join( " " ,parts );
this .textBox2.Text = result;
i want to modify this code to do this
:
this.textBox1.Text="My name is Waheed"
after reversing
"yM anem si heWade"
Length/2 then swap
ANY help please Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Using constants Hello,
I'm rewriting a C++ project into C#.
In the C++ project there are many constants defined like:
#define RECEIVE_BUFFER_SIZE_MAX 60
Is there some equivalent in C# or can I only use the C# dummy 'constant' variable like:
const byte receiveBufferSizeMax = 60;
This means I have to re-develop many functions because somehow C++ constants must be replaced by filled C# 'constant' variables.
Henk Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Runtime quick watch this is with regard to the new quick watch functionality in the Whidbey ide. I am talking about the box that appears when you position the cursor on an object during runtime and displays a wealth of information regarding the object.
. I would like to create such a tooltip and customise it for my own needs. Is this possible, I guess I need to look at the SDK for some specific classes. Can someone please point me in the right direction
I would appreciate any help and pointers Regards Tag: Visual C# General Conveting from bmp to pcx file Visual C#
Connection string/custom key-value pair from app config file [Assembly not win/Web forms] It doesn't make sense to have a App.config in a library project Move the App.config to your windows application (and configure it so that it's copied to the buildoutput), or add a new one with the same data and notice that it does work... Tag: Visual C# General Conveting from bmp to pcx file Visual C#