Click here to Skip to main content
15,892,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
M Sukhdeep13-Apr-16 11:55
M Sukhdeep13-Apr-16 11:55 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
Dave Kreskowiak13-Apr-16 12:05
mveDave Kreskowiak13-Apr-16 12:05 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
M Sukhdeep13-Apr-16 12:08
M Sukhdeep13-Apr-16 12:08 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
Dave Kreskowiak13-Apr-16 12:21
mveDave Kreskowiak13-Apr-16 12:21 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
Mycroft Holmes13-Apr-16 12:52
professionalMycroft Holmes13-Apr-16 12:52 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
Richard MacCutchan13-Apr-16 20:45
mveRichard MacCutchan13-Apr-16 20:45 
GeneralRe: HTTPListener with AuthenticationSchemes.IntegratedWindowsAuthentication Pin
Richard MacCutchan13-Apr-16 20:44
mveRichard MacCutchan13-Apr-16 20:44 
Questioncsharp creating algorithm Pin
Member 1245597512-Apr-16 21:24
Member 1245597512-Apr-16 21:24 
AnswerRe: csharp creating algorithm Pin
Peter_in_278012-Apr-16 22:13
professionalPeter_in_278012-Apr-16 22:13 
AnswerRe: csharp creating algorithm Pin
OriginalGriff12-Apr-16 22:19
mveOriginalGriff12-Apr-16 22:19 
AnswerRe: csharp creating algorithm PinPopular
BillWoodruff12-Apr-16 23:47
professionalBillWoodruff12-Apr-16 23:47 
GeneralRe: csharp creating algorithm Pin
OriginalGriff13-Apr-16 0:10
mveOriginalGriff13-Apr-16 0:10 
GeneralRe: csharp creating algorithm Pin
Richard MacCutchan13-Apr-16 0:44
mveRichard MacCutchan13-Apr-16 0:44 
GeneralRe: csharp creating algorithm Pin
BillWoodruff13-Apr-16 3:02
professionalBillWoodruff13-Apr-16 3:02 
GeneralRe: csharp creating algorithm Pin
Sascha Lefèvre13-Apr-16 3:51
professionalSascha Lefèvre13-Apr-16 3:51 
GeneralRe: csharp creating algorithm Pin
BillWoodruff13-Apr-16 5:02
professionalBillWoodruff13-Apr-16 5:02 
AnswerRe: csharp creating algorithm Pin
Patrice T13-Apr-16 9:14
mvePatrice T13-Apr-16 9:14 
Questionpuzzle, sub string not working Pin
Member 1016760412-Apr-16 21:20
Member 1016760412-Apr-16 21:20 
C#
Hi,
I was given following question as an assessment but unfortunately I was unable to answer. Can someone help ?
The question is ;
The function given below is supposed to retrieve the substring between and including the ith and jth characters of the input string s.  When i and j are out of range, ie. i,j< 0 ori,j >= s.length(), the function returns the string "<error>". The following table shows the expected and actual return values of the function for various inputs.


C#
Test case	s	      i	j	Expected return value	Actual return value
1	        "quick"	  0	2	"qui"	                 "qui"
2	        "brown"	  2	1	"ro"	                 ""
3	        "fox"	  1	9	"<error>"	             "<error>"
4	        "jumped"  -1	4	"<error>"	             "<error>"
5	        "lazy"	  3	0	"lazy"	                 "<error>"
6	        "dog"	  1	1	"o"	                     "o"


Unfortunately, the function returns the wrong value for the 2nd and 5th test cases.

C#
C# Version:
string SubString(string s, int i, int j)
{
      int k;
string result;
      try
      {
            k = s.Length;
            if (i < 0 || j < 0 || i >= k || j >= k)
                  throw new Exception();
            result = s.Substring(i, j + 1 - i);
      }
      catch (Exception e)
      {
            return "<error>";
      }
return result;
}
a) Under what general conditions does the function return the wrong value? 
 
b) Add some code to fix the function. Can you improve it? If so explain why your version is better.

AnswerRe: puzzle, sub string not working Pin
Richard MacCutchan12-Apr-16 21:25
mveRichard MacCutchan12-Apr-16 21:25 
QuestionCould not load file or assembly Pin
RAFish040412-Apr-16 8:26
RAFish040412-Apr-16 8:26 
AnswerRe: Could not load file or assembly Pin
Richard MacCutchan12-Apr-16 10:01
mveRichard MacCutchan12-Apr-16 10:01 
QuestionHow add a custom menu to Windows Explorer's tool bar Pin
srikrishnathanthri11-Apr-16 21:50
srikrishnathanthri11-Apr-16 21:50 
AnswerRe: How add a custom menu to Windows Explorer's tool bar Pin
Pete O'Hanlon11-Apr-16 22:22
mvePete O'Hanlon11-Apr-16 22:22 
GeneralRe: How add a custom menu to Windows Explorer's tool bar Pin
srikrishnathanthri12-Apr-16 3:51
srikrishnathanthri12-Apr-16 3:51 
QuestionRe: How add a custom menu to Windows Explorer's tool bar Pin
CHill6012-Apr-16 5:52
mveCHill6012-Apr-16 5:52 

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.