|
Ok cheers, I'll have a further play.
Jon
|
|
|
|
|
Hi,
How to retrieve sql database tables from the server for web application
|
|
|
|
|
"Need information quickly? No time to read about it? Check out these how-to videos."
http://msdn.microsoft.com/nl-nl/asp.net/bb498194(en-us).aspx#sql
|
|
|
|
|
What i want is,
accessing the system through public IP online & getting the sql database using c# through web applications.
|
|
|
|
|
Hi all,
Could someone perhaps give me a little more insight into the workings of the get and set properties?
Let's say I have the following class:
public class MyClass
{
private byte[] _myArray;
public byte[] MyArray
{
get { return _myArray; }
set { _myArray = value; }
}
public MyClass()
{
_myArray = new byte[10];
}
}
I can now access the member array of the class as follows:
byte[] NewArray = MyInstanceOfClass.MyArray;
and I can set it as follows:
MyInstanceOfClass.MyArray = new byte[] {0,1,2,3,4,5,6,7,8,9};
or
MyInstanceOfClass.MyArray = NewArray;
In all three examples I'm accessing the entire array as a unit. Is it also correct to access only individual elements of the array? Does the get/set properties allow for that or am I supposed to set them up differently?
By writing a little test app it seems to be working but is this the correct way of doing it?
byte MyByte = MyInstanceOfClass.MyArray[5];
and
MyInstanceOfArray.MyArray[5] = 123;
|
|
|
|
|
Yes, the content of an array is mutable.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: the content of an array is mutable
To follow on, you would be better to use methods to access the elements rather then the array:
public byte getItem(int item)
{
return MyArray[item];
}
public void setItem(int item, byte value)
{
MyArray[item] = value;
}
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
williamnw wrote: To follow on, you would be better to use methods to access the elements rather then the array
Why is that? To me it just seems more unwieldy. Here's an example why I think so:
Let's say you I have two instances of the above class and I want to set the value in one instance to be one bigger than the corresponding value in the other instance.
Using the methods as you recommend it would look like this:
MyFirstInstance.setItem(i, MySecondInstance.getItem(i)+1);
whereas, if using the get/set properties, it would look like this:
MyFirstInstance.MyArray[i] = MySecondInstance.MyArray[i]+1;
Both work, but to me the second line is just much more readable. Also, if I use the methods as suggested, I don't have access to MyArray.Length or any of the member methods of System.Array unless I explicitly code them.
What am I missing?
|
|
|
|
|
You're missing that the data is not being hidden.
If you WANT the array to be changed by an eternal class, then expose it, but it's not a great idea.
If you want the elements to be exposed then use a method that hides the implimentation.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Aha, so that's what mutability is. I've heard the term and read the quick definition - something like "a mutable class is one of which the contents can change". Duh! That hardly sounds like a useful description. At least now I have a practical example of where it becomes significant. Thanks.
|
|
|
|
|
Dewald wrote: now I have a practical example of where it becomes significant.
Objects of the String class are immutable, and used quite often...that's a pretty
significant practical example
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Cool, now I have two examples, thanks
|
|
|
|
|
Hello everyone,
I understand in the rule of C#, we are not allowed to add public/private/protected qualifier to methods in interface. My question is why adding the qualifiers are not allowed? I want to know the reason behind the claimed rule, i.e. what issues will be if we are allowed to add qualifier?
thanks in advance,
George
|
|
|
|
|
There is no purpose of having qualifiers for the members of an interface. If they are not public, they are not useable at all.
A private member doesn't make sense at all. Making a member protected would only force you to implement it, but it would not be reachable for any code that uses the interface.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa!
1.
I can understand that you mean if interface method is marked as private, then the implementation must be private and the implementation could not be accessed from outside? Is that your point?
2.
My confusion is what do you mean "Making a member protected would only force you to implement it, but it would not be reachable for any code that uses the interface."? Could you show some pseudo code to describe your ideas please?
regards,
George
|
|
|
|
|
Anything that's private in an object can only be accessed by that object itself so it is pointless in an interface as is protected as they can only be accessed by the class itself or ones derived from it.
I thought about this too when I first used interfaces. If all the objects that are going to implement the interface will have a specific private method for example then it makes sense to put the private method in the interface so each object has to implement it... If that were possible, it would save alot of typing (or copying/pasting) sometimes but that's not what interfaces are for!
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)
|
|
|
|
|
Hi Dave!
I disagree with you that in the implementation, we could provide accessor like private, here is my code with compile error when we add private qualifier to implementation method. Any comments?
interface IFoo
{
void Abc();
}
class Foo : IFoo
{
private void IFoo.Abc()
{
}
}
D:\Visual Studio 2008\Projects\TestInterface2\TestInterface2\Program.cs(15,22): error CS0106: The modifier 'private' is not valid for this item
regards,
George
|
|
|
|
|
Exactly my point - we can't because it would be pointless.
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)
|
|
|
|
|
Thanks Dave!
1.
Last confirmation, both methods in interface and methods in implementation class must be private?
2.
interface IFoo
{
void Abc();
}
class Foo : IFoo
{
private void Abc() {}
void IFoo.Abc() { this.Abc(); }
}
If yes to 1, I disagree. I did some investigation, seems when there is both implicit and explicit implementation, we could have a private implementation?
regards,
George
|
|
|
|
|
Hello everyone,
I have one confusion about strongly named assembly.
Suppose I am developing a library (DLL), and other application is linked with it (reference to the library DLL), my purpose is not to make the dependent application rebuild if I do not change the interface exposed to the application.
(i.e. if I just changed the implementation of the exposed interface and keep interface the same, application developer just need to copy my new library DLL, all other changes are transparent to application, and no need to rebuild.)
My question if I made the DLL strongly named, even if I keep the exposed interface the same (just change interface implementation), the application needs to rebuild? Why?
thanks in advance,
George
|
|
|
|
|
I want to build an application that can access the above mentioned contact list so a user can select multiple emails based off their existing address books.
Can anyone point me into the right direction for accessing those stored contacts?
|
|
|
|
|
Have you already looked into VSTO (Visual Studio Tools for Office)?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
No I haven't, do you have a url to VSTO?
Are you referring to http://msdn.microsoft.com/en-us/office/aa905533.aspx
or http://msdn.microsoft.com/en-us/library/d2tx7z6d(VS.80).aspx
?
If so, I trust they are both compatible with vs2008?
Thanks for the speedy informative reply! +5
|
|
|
|
|
The links that you posted look like they are for the VSTO msdn sections. VSTO is the premier Office authoring tool for Office 2007,2003. VSTO for VS2003 can target Office2003, VSTO for VS2005 can target Office2003, VSTOse2 for VS2005 can taget both offices, VSTO for VS2008 can taget both as well. VSTO comes depending upon the version of Visual Studio you have installed.
I personally have VS2008Pro (free to college students if you signup for DreamSpark[^]). This Visual Studio fully supports VSTO that can target Office 2003, 2007.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hey thanks buddy that really helped a lot, I'm a university student and this will save me a bundle (if applicable, I don't see why it wouldn't.)
Thanks again!
|
|
|
|