Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
AnswerRe: Own Mail Server with own domain Pin
Richard MacCutchan24-Jun-15 22:15
mveRichard MacCutchan24-Jun-15 22:15 
QuestionSaving stream as a PDF file to disk Pin
Member 1171394224-Jun-15 12:17
Member 1171394224-Jun-15 12:17 
AnswerRe: Saving stream as a PDF file to disk PinPopular
Sascha Lefèvre24-Jun-15 13:53
professionalSascha Lefèvre24-Jun-15 13:53 
GeneralRe: Saving stream as a PDF file to disk Pin
Member 1171394227-Jun-15 0:38
Member 1171394227-Jun-15 0:38 
QuestionHelp with Windows Form and IF statement Pin
Member 1147010024-Jun-15 9:04
Member 1147010024-Jun-15 9:04 
GeneralRe: Help with Windows Form and IF statement Pin
Sascha Lefèvre24-Jun-15 9:41
professionalSascha Lefèvre24-Jun-15 9:41 
GeneralRe: Help with Windows Form and IF statement Pin
Member 1147010024-Jun-15 11:19
Member 1147010024-Jun-15 11:19 
GeneralRe: Help with Windows Form and IF statement Pin
Sascha Lefèvre24-Jun-15 12:03
professionalSascha Lefèvre24-Jun-15 12:03 
Member 11470100 wrote:
My intention here, is to swap the images
Ah.. alright, I guess I could've seen that Big Grin | :-D

You have a small mistake in that first "block" (and maybe also in others, please check):
C#
Image p1 = pic1.Image;
string tag1 = pic1.Tag.ToString();
pic1.Tag = pic8.Tag;
pic8.Tag = tag1;
pic1.Tag = pic8.Tag;     // <--
pic1.Image = pic8.Image;
pic8.Image = p1;

The marked line is too many: You set pic1.Tag = pic8.Tag and pic8.Tag has been set to tag1 before, so both pic1.Tag and pic8.Tag are set to tag1.

Suggestions: pic1.Tag is a string anyway, right? Then just either cast it to a string (to satisfy the compiler), like so:
C#
string tag1 = (string)pic1.Tag;

..or declare tag1 as object. A String is an Object, so doing this doesn't actually change anything but clears up the code:
C#
object tag1 = pic1.Tag;


For swapping you could use a generic method[^], which also clears up the code and explains automatically what your intention is:
C#
public static class MyUtility
{
    public static void Swap<T>(ref T left, ref T right)
    {
        T temp;
        temp = left;
        left = right;
        right = temp;
    }
}

Then the whole code from above would look like this:
C#
MyUtility.Swap(ref pic1.Image, ref pic8.Image);
MyUtility.Swap(ref pic1.Tag, ref pic8.Tag);


Member 11470100 wrote:
will it be possible to schedule a skype setting so i can share screens and we could go through
We prefer to keep it in the forums here - if needed you could upload images to e.g. imgur.com and put the link into your message.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

QuestionStore one value from rows of data in a table Pin
Rajesh_198024-Jun-15 8:37
Rajesh_198024-Jun-15 8:37 
SuggestionRe: Store one value from rows of data in a table Pin
Richard Deeming24-Jun-15 8:51
mveRichard Deeming24-Jun-15 8:51 
GeneralRe: Store one value from rows of data in a table Pin
Rajesh_198025-Jun-15 4:15
Rajesh_198025-Jun-15 4:15 
QuestionCan we overload an abstract method of an abstract class? Pin
NJdotnetdev24-Jun-15 7:20
NJdotnetdev24-Jun-15 7:20 
AnswerRe: Can we overload an abstract method of an abstract class? Pin
Richard Deeming24-Jun-15 7:40
mveRichard Deeming24-Jun-15 7:40 
GeneralRe: Can we overload an abstract method of an abstract class? Pin
NJdotnetdev24-Jun-15 7:52
NJdotnetdev24-Jun-15 7:52 
AnswerRe: Can we overload an abstract method of an abstract class? Pin
maddymaddy1425-Jun-15 19:37
maddymaddy1425-Jun-15 19:37 
QuestionAn abstract singleton factory Pin
Marco Bertschi24-Jun-15 1:48
protectorMarco Bertschi24-Jun-15 1:48 
AnswerRe: An abstract singleton factory Pin
Eddy Vluggen24-Jun-15 2:35
professionalEddy Vluggen24-Jun-15 2:35 
GeneralRe: An abstract singleton factory Pin
Marco Bertschi24-Jun-15 2:48
protectorMarco Bertschi24-Jun-15 2:48 
GeneralRe: An abstract singleton factory Pin
Eddy Vluggen24-Jun-15 8:21
professionalEddy Vluggen24-Jun-15 8:21 
AnswerRe: An abstract singleton factory Pin
Richard Deeming24-Jun-15 4:29
mveRichard Deeming24-Jun-15 4:29 
AnswerRe: An abstract singleton factory Pin
Dave Kreskowiak24-Jun-15 5:17
mveDave Kreskowiak24-Jun-15 5:17 
QuestionExtension Methods in .NET 2 Pin
Member 1171394223-Jun-15 20:43
Member 1171394223-Jun-15 20:43 
AnswerRe: Extension Methods in .NET 2 Pin
OriginalGriff23-Jun-15 20:53
mveOriginalGriff23-Jun-15 20:53 
SuggestionRe: Extension Methods in .NET 2 Pin
Richard Deeming24-Jun-15 1:17
mveRichard Deeming24-Jun-15 1:17 
GeneralRe: Extension Methods in .NET 2 Pin
OriginalGriff24-Jun-15 1:34
mveOriginalGriff24-Jun-15 1:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.