Hey looking through the net I can’t seem to find a solution on how to pull these values out of this column of mine, I have only been developing for a year at Uni so this is all new to me.
Basically I don’t know how to do it, and reading up on Linq to SQL as well as conditional statements and loops hasn’t brought me any closer to finding my solution.
It’s as simple as this statement below:
public void SendToast(string title, string message)
{
var toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>{0}</wp:Text1>" +
"<wp:Text2>{1}</wp:Text2>" +
"</wp:Toast>" +
"</wp:Notification>";
var messageBytes = System.Text.Encoding.UTF8.GetBytes(toastMessage);
using (clientsDBDataContext clientDB = new clientsDBDataContext())
{
var client = new ServiceFairy.clientURI();
foreach (string r in client.uri)
{
Uri rs = new Uri(r.ToString());
SendMessage(rs, messageBytes, NotificationType.Toast);
}
}
}
I know for a fact I am doing it wrong but I just cant get my hands on how to fix this, if it wouldn’t be too much to ask, please explain how I am doing this wrong as I feel useless when I have to ask others to help me out with stuff I can’t figure out myself.
Thanks 🙂
This is the error Message I am getting:
Error 1 Cannot convert type 'char' to 'string'
What is this line doing?
Aside from the fact that this wouldn’t compile (it needs to be
new ServiceFairy()), what doesclientURI()return? You use it here like this:I suspect that
client.uriis actually a string. If not, what is it? Assuming it’s a string, then looping over any string in C# results in looping over the characters in the string. So I expect your compiler error is due to the fact that you are declaringras astring, but it’s actually achar. Most likely you don’t need a loop at all, but I can’t answer that until you explain whatclient.uriactually returns.And if you’re feeling generous, perhaps you can explain why you have a class named
ServiceFairy. 😉Edit:
Based on the comments, the code should go from:
To: