|
Long reply coming...
Bram van Kampen wrote:
public string NewPassword { get; set; }
What on earth does it mean, and how does it fit in the Language.
It create a property with get/set accessors. There will be some code auto-generated by C# to fill in the bodies for get/set. Since you're a C++ guy, you can think of that line automagically creating the following (hopefully familiar) C++ code:
private: string m_NewPassword;
public:
string get_NewPassword() {
return m_NewPassword;
}
string set_NewPassword(string Value){
m_NewPassword = Value;
}
It is also totally unclear to me which part of an operation is executed on the Server, and which on the Client, or how to control this.
I assume this is a Web Site/App. All C# is always executed on the server. Client browsers are only guaranteed to understand XML, X/HTML, CSS, JavaScript/ECMAScript (probably more). This line can get blurred due to auto-wiring up events, AJAX calls back to the server, runat="server" on script tags, etc. If you give examples, we can probably help better show what executes where.
I understand that #include is out in C#,actually the whole C-Pre-processor is out, which robs me of a number of well tried and tested debugging methods.
File includes are handled in VS as you add/remove them from the project. The .csproj file maintains a list of the file included (can be visually inspected by opening it in a text editor). There's no separation of definition and code, so there's no C# equivalent of header files. There is still extremely basic preprocessor directives, but only to the extent of what's described at C# Preprocessor Directives[^]. As for debugging, you can look into the System.Diagnostic[^] namespace to see if it will suit your needs (or at least help create a replacement for what you're used to).
Global Variables are out to, but, there is something called a 'namespace'
Namespaces are pretty much the same as C++ namespaces. There's no double-colon notations, and everything is dot-qualified. You declare a full namespace in a single line, or you can declare them individually for nested namespaces. The following are equivalent:
namespace A.B.C {
public class X {
}
}
namespace A {
namespace B {
namespace C {
public class X {
}
}
}
}
As you had said, there are no global-scope variables/constants. However, a workaround can easily be achieved by wrapping your 'globals' into a static class like so:
public static class GlobalVars {
public static int global_counter = 0;
public static string global_string = "Yep.";
}
The Third question is, does the framework code generated by 'Visual Web Developer 2010 Express' keep track of internet Session Status, or do I have to write substantial code myself to ensure that the database the site is using is:
-Aware of Other Users
-Arbitrates between DB Updates
-Remains consistent
The web site/app will automatically keep track of sessions for the visitors to the site via a Session state[^] collection on the Page object. However, the sessions are unaware of other sessions currently active on the site. It is more of a collection of objects that are stored on the server (in memory or database) and associated with a received session ID (via cookie/url value). There is an Application collection (System.Web.HttpApplicationState[^]) that does maintain consistency between all site visitors and can share data. You will need to take additional steps to ensure that the read/writes to the Application object are thread-safe (usually via Application.Lock/Unlock).
However, your question about the database maintaining consistency, arbitrating updates, and being multi-user aware is not handled by anything automatically in the web side of things. Database transactions (System.Data.Common.DbTransaction[^]) can be used to help maintain consistency and arbitrate database updates. Making your database code be multi-user aware will likely have to be created by you (depending on what the awareness needs to be).
|
|
|
|
|
I myself and still learning classes in c# 3.0 and I have finally understood the getters and setters to a certain extent.
First you must have an attribute set as private and within its own class. That means that no other method outside of its object can directly change the attribute.
You attribute:
class GetPassword
{
private string _NewPassword;
public string NewPassword
{
get{return this._NewPassword ;}
set{this._NewPassword = value ;}
}
}
private string _NewPassword;
Now outside the class in our main form:
private void button2_Click(object sender, EventArgs e)
{
GetPassword setPassword = new GetPassword();
setPassword.NewPassword = tbSetPassword.Text;
MessageBox.Show(setPassword.NewPassword);
}
Remember when an attribute is set to private in a class, it can not be directly accessed and change by a method outside of the class, so instead the method out side the class 'GetPassword' located in 'Form1' has to access a 'public' method within the class 'GetPassword'. In order to make the change to the private variable. In other words the public string 'NewPassword{}' in 'GetPassword' class, is the public method in this class that can access the private member.
Inside this 'NewPassword{get; set}' method we used the private variable 'this._NewPassword' so this implies and shows the attribute, only this method has access, no other methods. so our method:
setPassword.NewPassword = tbSetPassword.Text;
is actually setting the private member '_NewPassword' by using:
set{this._NewPassword = value ;}
and the button method statement:
MessageBox.Show(setPassword.NewPassword);
Is actually returning the private members '_NewPassword' that had just been set by the user clicking on the button:
get{return this._NewPassword ;}
Sorry if it seems like gibberish but just got off work and trying to leave the building.
modified on Friday, July 29, 2011 5:20 PM
|
|
|
|
|
I have got one question just now can anybody help me?
on the C#,there is value on the any textbox,for exaple textbox1,value is 40,what kind code ı must write to see value of textbox1 on the progressbar1 grafik %40
|
|
|
|
|
Something like progressBar1.Value = int.Parse(textBox1.Text); perhaps?
Of course that will die if you type anything that can't be parsed to an int.
|
|
|
|
|
I'm assuming win forms... You can't draw text on the ProgressBar. There are others around on here that will allow it, have a look here[^]
It's not too difficult to roll your own too!
P.S. Next time, please use a descriptive subject.
|
|
|
|
|
Hi,
Can anyone help me to find Filtering option in columns
I want to know what are the different options for data filtration available for grid supports and which works best in terms of data updating, sorting or any other data related tasks.
|
|
|
|
|
Your question is exceedingly generic. What are you really trying to do?? (And don't say "filter columns") Provider as much detail as possible. "Filtering" can be done in a mirad of ways, but what's "best" depends on what you're doing and how much data you're talking about.
|
|
|
|
|
dessiymartin wrote: what are the different options for data filtration available for grid
None, I'm fairly sure. Filtering can be done by a DataView though. See the DefaultView[^] property of the DataTable class.
|
|
|
|
|
Interesting question.
We can filter rows in a grid by setting filtering conditions via IFilter interface or by directly calling Row.Filtered property.
e.g. setting boolean in the Row.Filtered property and implementing the IFilter interface and setting it with the Grid.Filter property.
This approach covers almost all situations when data filtering may be needed. Filters in column work in parallel with programming filter set via Grid.Filter property. Any of these filters can tell the grid that data should no longer be visible. Have a look if you want to know in detail about data filters in columns
|
|
|
|
|
How can I check if my IIS is alive using C#?
If the server is down - how to do iisreset ?
|
|
|
|
|
|
looking for help with regex format
i need only numbers with this format:
05########
0########
and
05#-#######
0#-#######
|
|
|
|
|
wouldnt that be something like:
^05[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
^0[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
^05[0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
^0[0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
i think
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
(We have a Regular Expression forum.)
How about: 05?\d-?\d{7}
|
|
|
|
|
PIEBALDconsult has given you the answer, but he is also correct: there is a regex forum[^] which is more appropriate.
If you are going to use regexes in future (or you want to understand the one PIEBALDconsult gave you), get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Hi,
How can I fetch a collection of an entity with a filtered collection of children of that entity in a query not using foreach and so on.
For example I have 2 entities : Student & Grade
I want to fetch all Students and Grades that are more than 15
Best wishes
|
|
|
|
|
Is there an association between Student and Grade? Grade is child of Student and a Student can have multiple Grades? If so I would think a LINQ query would be easiest...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes Mark, there is an association between them and Grade is child of Student and a Student can have multiple Grades.
Actually I want do it via LINQ query but I couldn't.
Best wishes
|
|
|
|
|
If you can post an example of what you tried then maybe someone here can help fix it
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i think i know there aren't really pointers in c# as such but... if i have a class so:
public class {
int id;
string name; <---- not much data
byte [] data; <---- could be a few mb of data
}
and i need to populate a combobox with name & id values should i simply use the existing class as a combobox item OR should i define a new class just for this scenario?
thnx
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
I don't see anything related to pointers there.
Since you have a reference class with all references, there's really no need to create another class unless you get some gain out of it. What are you thinking the issue is here?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
well ok so i have a List<> of POCO objects that are serialized into json and back for transport over the wire from a web service ... now i don't send the actual data bytes with the list of items just the id and name (the data bytes can be several mb) and request the actual data bytes on demand ... once they are loaded from the server they are stored in memory in the List<>
my main form has a function to get a given document from the List<> ... that causes the doc class to see if the data is there, and if not, go get it and set a flag saying we have it now
then it returns the doc.doc_data which is a byte [] variable
my actual question is this: when i do "return doc.doc_data" does it make a copy of the data on the stack and pass it back, or does it simply return a ptr / ref to that data?
the 1st option would be very bad .... the 2nd is what i hope happens but i don't know how to tell what it is doing
hope that explains it better
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
l a u r e n wrote: my actual question is this: when i do "return doc.doc_data" does it make a copy of the data on the stack and pass it back, or does it simply return a ptr / ref to that data?
Depends on the code in the property/method returning the array... is it making a copy and returning a reference to that copy or just returning a reference to the original data?
Arrays are reference types.
For reference types you need to explicitly make a copy of the data to have two copies. Otherwise a reference refers to the same object, even if you make a copy of the reference.
Pointers are so not relevant here...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i know pointers aren't really the thing here
i guess i was asking if the function returns a pointer to the data or a copy of the data
that's what i do not quite get in c#
lets say i have a class:
class doc {
int doc_id;
string doc_title;
byte [] doc_data;
public doc()
{
doc_id = 0;
doc_title = string.Empty;
doc_data = null;
}
byte [] getdoc()
{
if (doc_data == null){
doc_data = get_the_data_from_somewhere_over_the_network(id);
}
return doc_data;
}
}
does the getdoc() function return a copy of the data or a ptr to the data?
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
l a u r e n wrote: does the getdoc() function return a copy of the data or a ptr to the data?
It returns a reference to doc_data. No copy is made. The reference "refers" to the same exact data the doc_data field "refers" to.
l a u r e n wrote: i guess i was asking if the function returns a pointer to the data or a copy of the data
that's what i do not quite get in c#
In .NET, this is arguably THE fundamental thing that must be understood, especially if you come from a language like C/C++. Except for simple classes that are defined as value types (which are copied when you do an assignment), most classes are reference types, so any time you pass/return objects of those classes you pass/return references to an object - the SAME object. The implication is that if you alter that object, every other place there's a reference held on that same object is effected.
This MUST be understood... Types (C# Reference)[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|