1
Answer

Position of a string

Photo of harish reddy

harish reddy

7y
224
1
 
//Write a program in C# Sharp to search the position of a substring within a string. Not able to get the output and proceed further.... pls help
string sentence = Console.ReadLine();
foreach (string item in sentence)
{
Console.WriteLine(item);
}
int pos = 1;
Console.WriteLine("Enter the substring");
string substring = Console.ReadLine();
char[] substringchar = substring.ToCharArray();
 

Answers (1)

0
Photo of Altaf Ansari
NA 1.4k 27.4k 7y
Hello Ravi, Please store the user Detail in DataBase specially ID which is generated by HUB, with respective Users..
 
 
And Check each time while user login the application..
 
 
  1. public void Connect(string userName)  
  2.         {  
  3.             var id = Context.ConnectionId;  
  4.   
  5.             // Getting ID from DataBase if Exist  
  6.             string LoginId = ConnC.GetColumnVal("Select LoginId from Users Where UserName='" + userName + "'""LoginId");  
  7.   
  8.             if (LoginId == null || LoginId != ""// Updating ID in DataBase if Not Exist  
  9.                 ConnC.ExecuteQuery("Update Users set LoginId='"+ id + "' where UserName='" + userName + "'");  
  10.   
  11.             if (ConnectedUsers.Count(x => x.ConnectionId == id) == 0)  
  12.             {  
  13.                 string UserImg = GetUserImage(userName);  
  14.                 string logintime = DateTime.Now.ToString();  
  15.   
  16.                 if (LoginId != id)  
  17.                     ConnectedUsers.Add(new Users { ConnectionId = id, UserName = userName, UserImage = UserImg, LoginTime = logintime });  
  18.                 // send to caller  
  19.                 Clients.Caller.onConnected(id, userName, ConnectedUsers, CurrentMessage);  
  20.   
  21.                 // send to all except caller client  
  22.                  
  23.                     Clients.AllExcept(id).onNewUserConnected(id, userName, UserImg, logintime);  
  24.             }  
  25.         }