|
hey
I have a property:
int MyProperty{<br />
get{return myProperty;}<br />
}
When we ran FXCop it threw up:
Info : "Do not use names that require case sensitivity for
uniqueness. Components must be fully usable from both
case-sensitive and case-insensitive languages. Since
case-insensitive languages cannot distinguish between
two names within the same context that differ only
by case, components must avoid this situation."
So what should I rename myProperty?
cheers
|
|
|
|
|
Hi,
I do this all the time, but only in specific situations; i.e.
the local variable is declared private, and the property is either
protected or public.
And I do not intend on changing that. How else would you come up with
two different but related names (don't give me the underscore stuff,
such as _myProperty or m_myProperty, I don't like it at all, it lowers
the readability of the code).
Did you add those different qualifiers when trying?
If myProperty and MyProperty both were to have the same access rights
(which is private if you dont specify), then I would agree with FxCop.
|
|
|
|
|
I do it the same.
Which .NET language is actually case insesitive?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I dont know, and I would be surprised if any of the major ones
would be case-insensitve. I read all languages but on CLR I only speak C#
I do know a lot of "cross-linkers" (I am an embedded guy actually) are either
case-insensitive or have a switch to let the user choose.
|
|
|
|
|
Visual Basic, Eiffel for starters.
However, FxCop should really only be objecting about public identifiers that differ only by case. It shouldn't really object to the original example and I would disable that rule.
Kevin
|
|
|
|
|
Luc Pattyn wrote: (don't give me the underscore stuff,
such as _myProperty or m_myProperty, I don't like it at all, it lowers
the readability of the code).
Just my opinion, but I rather like the m_propertyName way of doing it. With a quick glance in a function you can tell whether or not the code is operating on a member or a local, and also groups them all together in Intellisense so you can easily search through your member variables.
|
|
|
|
|
Hi Phil,
That is absolutely true, but it does not change the fact
I don't like how it looks.
Some people still prefix a polish-style type indicator to every
variable, as in string strMyName;
I prefer identifiers to be strictly functional;
I do prefix interface names with "I" since that is a hard convention;
and I tend to prefix Controls with their type ("frm", "pan", "btn", ...)
mainly to be able to do things such as bool caseSensitive=cbCaseSensitive.Checked;
but that is all.
I do understand large organizations should impose strict rules,
and the larger the project the more it may benefit from them,
and from having some prefixes such as the m_ for members.
|
|
|
|
|
thepersonof wrote: So what should I rename myProperty?
To something meaningful.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hello Every body,
I want to generate crystal reports.
But I am unable to do so.
I had included an crystal report through add new items.
but i am not able to create report.
Regards,
rahul saini
|
|
|
|
|
|
do u binded the XXXX.rpt with the crystal report viewer.if not do it and check.
prasanna muthuramalingam
|
|
|
|
|
Hi,
Thanks for rplying me.
I had used crystal report viewer I am getting result but i want the result that i need Is is howing all the records . It is not showing the records corresponding to the sql query that i gave it.
Regards
rahul saini
|
|
|
|
|
I have noticed the following tags in a code can any one tell be how to frame this
[XmlRoot("DeleteEventsRequest", Namespace = "uri")]
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
i have designed a code that will add a control on panel of the form and then if i want to delete it it will delete the code by pressing delete key.
the control code is as follows
public partial class NO : UserControl
{
public NO()
{
InitializeComponent();
}
private void NO_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] points = { new Point(0, 42), new Point(15, 42), new Point(15, 25), new Point(15, 63), new Point(30, 25), new Point(30, 63), new Point(30, 42), new Point(47, 42) };
g.DrawLines(Pens.Black, points);
g.Dispose();
}
private void txt_no_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
lbl_no.Text = txt_no.Text;
lbl_no.Visible = true;
txt_no.Visible = false;
}
}
private void lbl_no_DoubleClick(object sender, EventArgs e)
{
lbl_no.Visible = false;
txt_no.Visible = true;
}
}
while the control is added on the form on a click event
private void NO_Click(object sender, EventArgs e)
{
NO no_obj=new NO();
no_obj.Location = new Point(x, y);
fpanel1.Controls.Add(no_obj);
x += 50;
no_obj.Click += new EventHandler(no_obj_Click);
}
void no_obj_Click(object sender, EventArgs e)
{
c = (NO)sender;
c.KeyDown += new KeyEventHandler(c_KeyDown);
}
void c_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
fpanel1.Controls.Remove(c);
}
}
the code works fine on click event.
my problem is that when i insert any text in text box and then try to delete my control using DELETE key it will not delete it.
plz send some suggestion so that i m able to resolve this problem on keypress event.
|
|
|
|
|
Hello,
trulyyy wrote: my problem is that when i insert any text in text box and then try to delete my control using DELETE key it will not delete it.
The problem is that the TextBox holds the focus and the KeyDown event of the UserControl doesn't get fired.
You also have to handle the MouseDown of all other Controls (including TextBox) which are on the UserControl.
But anyway, this code is a big mess!
Please try to use meaningfull names, and also use the "pre"-Tags if you post code here on the forum.
trulyyy wrote: void no_obj_Click(object sender, EventArgs e)
{
c = (NO)sender;
c.KeyDown += new KeyEventHandler(c_KeyDown);
}
If the user Clicks the second time on the UserControl you will have the KeyDown fired twice.
trulyyy wrote: g.Dispose();
This is a very bad idea, and will have strange effects in your program.
You should not Dispose objects which you have not created.
All the best,
Martin
|
|
|
|
|
i have design a controle using following code
private void NO_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] points = { new Point(0, 42), new Point(15, 42), new Point(15, 25), new Point(15, 63) };
Point[] points2={ new Point(30, 25), new Point(30, 63), new Point(30, 42), new Point(47, 42) };
g.DrawLines(Pens.Black, points);
g.DrawLines(Pens.Black, points2);
g.Dispose();
}
private void lblNO_Click(object sender, EventArgs e)
{
lblNO.Visible = false;
txtNO.Visible = true;
}
private void txtNO_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
lblNO.Text = txtNO.Text;
txtNO.Visible = false;
lblNO.Visible = true;
}
}
private void NO_Click(object sender, EventArgs e)
{
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
}
when i placed it on form and then i want to delet it
i am using the following code for that purpose
private void button1_Click(object sender, EventArgs e)
{
NO un = new NO();
un.Location = new System.Drawing.Point(X, Y);
un.Refresh();
un.Size = new Size(100, 100);
Controls.Add(un);
un.Click += new EventHandler(un_Click);
X += 50;
}
void un_Click(object sender, EventArgs e)
{
c = (UserControl)sender;
c.KeyDown += new KeyEventHandler(c_KeyDown);
}
void c_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
this.Controls.Remove(c);
}
}
but when i dont touch the control and as it delete it
it would be deleted when i change the value of lable on control the above code is not working.
|
|
|
|
|
cuteAisha wrote:
g.Dispose();
Don't dispose a graphics object that you haven't created yourself.
cuteAisha wrote: but when i dont touch the control and as it delete it
it would be deleted when i change the value of lable on control the above code is not working.
I have no idea what you are trying to say. I get that the code is not working, and that it has something to do with changing the value of the label, and something about deleting the control. I can't tell what's happening or if the control is deleted when it shouldn't or if it isn't deleted when it should.
---
single minded; short sighted; long gone;
|
|
|
|
|
i want to delete control on key press
control is generated on click event of button
when user click lable on control a textBox is displayed
user may enter input for control funtion in the text box
when user press enter key text of textBox is assign to lable
and its visible property is equal to false.
this code which is given on forum proved all above funtionality
but when user assing a input now that control is not delete
on the other hand if user don't click on input lable now that coutrol will deleted
i cant undestand what the problem is?
why in some conditions it working and why not in a scecific condition.
|
|
|
|
|
Hi,
I dont understand all of it;
not using the PRE tags makes this harder to read than is necessary.
But with what I can figure out, seems to me there are many mistakes:
1.
g.Dispose(): as Guffa already said, dont dispose of things you did not create.
2.
I am puzzled by your NO_Click()
cant figure out what control would invoke this, nor what sense it makes
just changing a border style.
Showing the constructor might have been useful...
3.
on button1_Click you create a new NO
so every time it happens another NO is added, 50 dots to the right of the
previous one? is that really the intention?
if you only need either none or one NO object, I suggest you create it beforehand
(probably using Designer) and keep it invisible until you want to see it.
4.
un_Click(): why is it you set the keydown event only after having clicked "un" ?
I guess you could have done that right away, it would only fire when is has
focus anyway. You are making things more complex than necessary.
5.
it might help us if you better explain (and show code about):
- what the intial state should be and is;
- what the functionality of the NO class is;
- and exactly what goes wrong, after exactly which actions the user takes.
But maybe you first want to clean-up your code based on the above input,
then replublish it inside PRE tags (have a look at other messages, then
use the little "pre" button under the window where you enter your messages...
|
|
|
|
|
i want to know how to connect the application to the db and create the user logins in the db via the application.do you have any idea....
|
|
|
|
|
prasadbuddhika wrote: i want to know how to connect the application to the db
SqlConnection conn = new SqlConnection(theConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = anySqlCommand;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
theConnectionString is defines where and how to connect to your database. For the functions you wish to carry out you will need a connection with sysadmin privileges. See http://www.connectionstrings.com[^] for details on what connection strings look like.
anySqlCommand is a string that can be pretty much any command that SQL Server understands. You can even dump entire scripts in there. The only thing it can't deal with is the GO, because that isn't SQL, it is a delimiter that Query Analyzer or the SQL Server Management Studio uses to separate batches of SQL statements.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi,
I have a form Form1 I want to refresh the form after every 10 seconds how to implement this.
|
|
|
|
|
you can just use a timer from System.Threading namespace.
|
|
|
|
|
Hi Ekynox,
Thanks for reply....
Actually I have a DataGridView in Form1 in my Windows Application and now i want to refresh the datagridview every some time....
Can u help me with a sample code....
|
|
|
|
|
do you know how to fill a datagridview ? then put the code that fills a datagridview inside the timer object. cant be that hard.
|
|
|
|
|