|
Byte c_sum;
c_sum = 0;
I got this error when assign c_sum =0. Really can not understand why?
|
|
|
|
|
The second line is a statement, not a declaration. Statements has to be inside a method.
Perhaps you meant to use an initializer in the declaration:
byte c_sum = 0;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
No, it did not work. My code suddenly have so many funny errors like that ?
|
|
|
|
|
Can you offer more information? More code would be better.
Tan Li
I Love KongFu~
|
|
|
|
|
It sounds like your starting and ending brackets doesn't match, so that you get methods inside another method or statements outside a method.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
if it is a struct, you can't provide initial values to struct members like that.
Use the constructor to initialize all members.
|
|
|
|
|
Not sure if this is the correct forum, but here goes
I have a string eg
string myString = "Setting17=50";
Now i want to get a substring from it by specifying 2 strings (start and end), ie i specify "Setting" and "=" and it returns 17. Can i do this with regular expressions? (if so any pointers would be great), or do i have to do string manipulation? (ie get the right of "settings" and then the left of "=")
Regards
Mark
|
|
|
|
|
You can create a pattern from starting and ending strings:
string start = "Setting";<br />
string ending = "=";<br />
<br />
string pattern = Regex.Escape(start) + "([\w\W]*)" + Regex.Escape(ending);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
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
|
|
|
|