|
You could also use Split
string splitParts[] = myString.split('=');
splitParts[0] will be "Setting17"
splitParts[1] will be "50"
|
|
|
|
|
Thanks Guys, got it all sorted
|
|
|
|
|
Hi,
I want to find the "Rotations Per Minute" property of my hard drive using C#.
I tried using the "System.Management.ManagementObject" class with the query "SELECT * FROM Win32_DiskDrive". It returned a number of properties, but not the RPM property. I also checked the values of all the properties, in case the RPM property wasn't named "Rotations Per Minute", but none of the values were 7200.
Help please ...
|
|
|
|
|
I have some calculation after calculating all data stores in SQL Server2005. i want add a pop up window which will be finished after storing into data base. how can i do that. please help me its urgent..
Shafik
|
|
|
|
|
u can design ur ownpopup window using normal form and can open that form
before starting the calculation and then can close that form after storing into data base.
rahul
|
|
|
|
|
Hi,
I'm doing TCP/IP programming to transfer data between Client and Server. When i write and read my BYTE [] size is constant size, I believe that if i know the available free band width of TCP port that can be utilized fully to improve the throughput.
How can i achieve this.
Thanks ....
|
|
|
|
|
How should I use enumeration (correctly) with a public variable please?
My code below crashes Visual Studio when I attempt to build it. Without the enumeration section it works fine. Where am I going wrong please?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections.ObjectModel;
namespace MultiColumnComboBox
{
public partial class MultiColumnComboBox : ComboBox
{
private List<column> values = new List<column>();
public class Column
{
private bool _autoWidth = true;
private int _columnWidth;
private bool _visible = true;
[Category("Parameters")]
[DisplayName("Auto Width?")]
public bool AutoWidth
{
get { return _autoWidth; }
set { _autoWidth = value; }
}
[Category("Parameters")]
[DisplayName("Column Width")]
public int ColumnWidth
{
get { return _columnWidth; }
set { _columnWidth = value; }
}
[Category("Appearance")]
public bool Visible
{
get { return _visible; }
set { _visible = value; }
}
public enum ColumnType
{
Image = 0,
Data = 1,
Checkbox = 2
}
[Category("Parameters")]
[DisplayName("Column Data Type")]
public ColumnType columnType
{
get { return columnType; }
set { columnType = value; }
}
}
public class ColumnEditor : CollectionEditor
{
public ColumnEditor()
: base(typeof(List<column>))
{}
protected override object SetItems(object editValue, object[] value)
{
return base.SetItems(editValue, value);
}
protected override string GetDisplayText(object value)
{
Column item = new Column();
item = (Column)value;
return base.GetDisplayText(string.Format("Column", item.AutoWidth, item.ColumnWidth));
}
}
public MultiColumnComboBox()
{
InitializeComponent();
}
[Category("Columns")]
[DisplayName("Columns")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[RefreshProperties(RefreshProperties.All)]
[Editor(typeof(ColumnEditor), typeof(UITypeEditor))]
public List<column> Values
{
get { return values; }
}
}
}
</column></column></column></column>
modified on Tuesday, January 6, 2009 6:48 AM
|
|
|
|
|
Is the error that you are getting a 'Stack Overflow'?
In your code you have created a circular reference. The columnType getter/setters call themselves looping ad infinitum
Your Code:
<br />
public enum ColumnType<br />
{<br />
Image = 0,<br />
Data = 1,<br />
Checkbox = 2<br />
}<br />
<br />
<br />
[Category("Parameters")]<br />
[DisplayName("Column Data Type")]<br />
public ColumnType columnType<br />
{<br />
get { return columnType; }<br />
set { columnType = value; }<br />
}<br />
Try:
<br />
public enum ColumnType<br />
{<br />
Image = 0,<br />
Data = 1,<br />
Checkbox = 2<br />
}<br />
<br />
private ColumnType columnType<br />
<br />
[Category("Parameters")]<br />
[DisplayName("Column Data Type")]<br />
public ColumnType ColumnType<br />
{<br />
get { return columnType; }<br />
set { columnType = value; }<br />
}<br />
I have bolded the changes.
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
Many thanks Henry. VS now reports:
public enum ColumnType
{
Image = 0,
Data = 1,
Checkbox = 2
}
private ColumnType columnType
[Category("Parameters")]
[DisplayName("Column Data Type")]
public ColumnType ColumnType < ----- already contains a definition for 'ColumnType'
{
get { return columnType; }
set { columnType = value; }
}
|
|
|
|
|
Yes. Silly of me.
This is because you are declaring the enum inside your class.
Try changing public enum ColumnType to public enum ColumnTypes (all I've done is add an 's') making sure to change all the references to it. I suggest doing this by using the Refactor|Rename context menu option.
If this works, and I think it will, you might consider moving the enum declaration outside the class, unless it will only ever be used within the class.
e.g.
Instead of
<br />
public partial class MyClass<br />
{<br />
public enum MyEnum<br />
{<br />
.....<br />
.....<br />
}<br />
<br />
.........<br />
.........<br />
.........<br />
}<br />
to:
<br />
public enum MyEnum<br />
{<br />
.....<br />
.....<br />
}<br />
<br />
public partial class MyClass<br />
{<br />
<br />
.........<br />
.........<br />
.........<br />
}<br />
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
Yes, moving the enum outside of my class is the way to go.
Please accept to grateful thanks. I had got myself into a pickle
Now back to weaving the magic ...
|
|
|
|
|
Pleased I could help.
Incidentally, you should be congratulated for posting a question with source code. It makes it sooooo much easier to formulate a response. Other CPians considering asking for help should follow your example.
Honi soit qui mal y pongs - Evil to he who thinks it stinks
|
|
|
|
|
hi all
I have an application...in that am taking snap from webcam and saving it to the databse...
In sql databse the path is saving...the picture is saving in to the bin folder of the application
and that path is saving to databse.....
is it possible to create a folder in the application like "Images" and save the images in this folder?
one more doubt
how will i take this image in crystal report?..
if am stroring the image as binary,its working fine....but it is taking lots of memory...so i want to change like this....
can anybody help me to overcome this issue?....
any help is appreciated in advance....
|
|
|
|
|
HI,
Please guide me to convert PPT files to JPEG files.
Thanks in advance...
|
|
|
|
|
You can create a Virtual Printer from which you can get the EMF version of your PPT.
Then use GDI+ to load this EMF and save it as JPEG.
«_Superman_»
|
|
|
|
|
hello everyone,
i am using ms-access database to store special character corresponding hexavalue.The special character is 1409 with hexavalue. when user open the html file the special charcter shuld be replaced with hexavalue.
i am using this code to match with database....
string aaa = xx.ToString();
int stat = 0;
OleDbConnection mycon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Administrator\\Desktop\\Splchar.mdb;Persist Security Info=False");
OleDbCommand cmd = new OleDbCommand("select * from splchar", mycon);
try
{
mycon.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string xx1 = reader.GetValue(1).ToString();
stat = richTxt.Find(reader.GetValue(1).ToString(), 0, RichTextBoxFinds.MatchCase);
while (stat != -1)
{
richTxt.SelectedText = Reader.GetValue(2).ToString();
stat = richTxt.Find(reader.GetValue(1).ToString(), stat + 1, RichTextBoxFinds.MatchCase);
}
}
reader.Close();
mycon.Close();
but its did't convert properly special character to hexavalue..
Please help me...!!
|
|
|
|
|
Hello everyone,
I am using the following code to generate result of MD5 to a string, my question is how to convert it to an int? The string is 16 bytes, too big for an int.
My purpose is to get the hash code for an input string, but result in the form of an int.
string a = "Input String";
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
System.Text.Encoding enc = System.Text.Encoding.UTF8;
StringBuilder resultBuffer = new StringBuilder();
byte[] result = md5.ComputeHash(UTF8Encoding.Default.GetBytes(a));
for (int i = 0; i < result.Length; i++)
{
resultBuffer.Append(result[i].ToString("X"));
}
string resultStr = resultBuffer.ToString();
regards,
George
|
|
|
|
|
Depending on what you want to use the int/hashed string for you could just make the sum off the bytes (if memory serves me right MD5 hashing returns only numeric values).
|
|
|
|
|
Hi Tom,
1.
MD5 hashing returns byte[] other than numeric value in C#. Please feel free to correct me if I am wrong.
2.
"you could just make the sum off the bytes" -- interested in this. Any more details or pseudo code?
regards,
George
|
|
|
|
|
George_George wrote: MD5 hashing returns byte[] other than numeric value in C#. Please feel free to correct me if I am wrong.
Like I said 'if memory serves me right' so could be been a while since I looked into the hashing.
So I could be wrong about that
(just found some code I used a while ago for the md5 hashing)
Public Shared Function GetMD5Encrypted(ByVal input As String) As String
Dim md5hasher As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()
Dim hashedbytes() As Byte
Dim encoder As New UTF8Encoding()
hashedbytes = md5hasher.ComputeHash(encoder.GetBytes(input.ToCharArray()))
Dim hashedstring As String = Nothing
For Each i As Integer In hashedbytes
hashedstring = hashedstring + i.ToString
Next
Return hashedstring
End Function
(sorry about the vb.net language but you should be able to convert it)
I think this one only returns numeric values, but you might want to check that first.
George_George wrote: "you could just make the sum off the bytes" -- interested in this. Any more details or pseudo code?
Don't really have any code for it, it was just my first thought and what I would try to do first. (but if there only numeric values in the hash it's simple, if not you'll probably have to do a check if the byte is numeric or not if not you could use the Asci value of the char or something else)
|
|
|
|
|
Thanks Tom,
1.
I read your VB code. It returns string other than returns int. What I want is to get int (32-bit output). Any comments?
2.
"Don't really have any code for it, it was just my first thought and what I would try to do first. (but if there only numeric values in the hash it's simple, if not you'll probably have to do a check if the byte is numeric or not if not you could use the Asci value of the char or something else)" -- I read it twice, but do not understand. It is appreciated if you could some pseudo code for this idea? Code makes everyone clear.
regards,
George
|
|
|
|
|
Well like I said it's a thought and I'm not sure you'll always get a unique value out off it but here is some pseudo code anyway.
'the hashed string
String Hash="1564897548846357815";
Char c ;
Int result;
for each c in hash
if isnumeric(c) then
result = result + c
else
'do something to convert the char into an int
end if
next
Now I seriously doubt that this will work (reading the comments off other reply's to your post), but it was my first thought and you never know.
It also depends on for what you'll use the int (if it has to be unique I wouldn't do it like this).
PS: sorry if my c# code isn't perfect, been a while since I coded in it
|
|
|
|
|
George_George wrote: but result in the form of an int.
Why George ?
cheers,
Abhijit
CodeProject.Com MVP
|
|
|
|
|
Hi Abhijit,
It is legacy system interface limitation. It has to use 32-bit int. Any ideas to convert a string into 32-bit int? The best idea I could think of is to calculate hashing for the input string. But the hashing result is not 32-bit, so I am thinking about how to convert it...
Any comments or ideas?
regards,
George
|
|
|
|
|
Don't know if you've sorted this or not George but thought I'd throw in my 2c worth.
As you know MD5 is 128bit (16 bytes) so there's no way of getting a unique value into an Int32. The same applies to Int64.GetHashCode() method - if you test it, you'll find you will get identical results for different values as it's impossible to make 64 fit into 32.
There are 32 bit hash algorithms out there - if it's just for file checking etc then it will be good enough, but if it's for security then forget it. If it's just for the sake of turning an arbitary string into an int then use GetHashCode() on your string.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|