This is the controller code for a .svc file. It is not apparent as to why i receive the following error! I believe that it states their is something wrong with type or format of public access modifier for this version state supposedly.
if (hero1.Combat > hero2.Combat)
{
return $"{hero1.HeroName} wins!";
}
if (hero2.Combat > hero1.Combat)
{
return $"{hero2.HeroName} wins!";
}
return "its a tie!";
}
}
}
Severity Code Description Project File Line Suppression State Error CS0106 The modifier 'public' is not valid for this item SuperHeroDB C:\Users\Andrew\Documents\Visual Studio 2015\MyProjects\SuperHeroDB\SuperHeroDB\Service\SuperHeroService.svc.cs 140 Active Error CS8652 The feature 'local function attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.
SuperHeroDB C:\Users\Andrew\Documents\Visual Studio 2015\MyProjects\SuperHeroDB\SuperHeroDB\Service\SuperHeroService.svc.cs 136 Active
You did not share all the relevant code so I'm guessing. Operational contracts are Interfaces which do not have access modifiers or a body of code. The implementation of the Interface has these features. An Operation contract has the following pattern
and within an Interface
Member
251 Points
423 Posts
Access Modifier error.
May 04, 2020 07:34 PM|Markus33|LINK
This is the controller code for a .svc file. It is not apparent as to why i receive the following error! I believe that it states their is something wrong with type or format of public access modifier for this version state supposedly.
Link: https://ibb.co/znTV0dH
[OperationContract]
[WebInvoke(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "Fight/{Id1}/{Id2}", Method = "GET")]
public string Fight(string Id1, string Id2) //error code! (public)
{
SuperHero hero1 = Data.SuperHeroes.Find(hero => hero.Id == int.Parse(Id1));
SuperHero hero2 = Data.SuperHeroes.Find(hero => hero.Id == int.Parse(Id2));
if (hero1.Combat > hero2.Combat)
{
return $"{hero1.HeroName} wins!";
}
if (hero2.Combat > hero1.Combat)
{
return $"{hero2.HeroName} wins!";
}
return "its a tie!";
}
}
}
Severity Code Description Project File Line Suppression State
Error CS0106 The modifier 'public' is not valid for this item SuperHeroDB C:\Users\Andrew\Documents\Visual Studio 2015\MyProjects\SuperHeroDB\SuperHeroDB\Service\SuperHeroService.svc.cs 140 Active
Error CS8652 The feature 'local function attributes' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.
SuperHeroDB C:\Users\Andrew\Documents\Visual Studio 2015\MyProjects\SuperHeroDB\SuperHeroDB\Service\SuperHeroService.svc.cs 136 Active
All-Star
53691 Points
24031 Posts
Re: Access Modifier error.
May 04, 2020 07:58 PM|mgebhard|LINK
You did not share all the relevant code so I'm guessing. Operational contracts are Interfaces which do not have access modifiers or a body of code. The implementation of the Interface has these features. An Operation contract has the following pattern and within an Interface
The implantation of the Interface has method body.
You've been on these forum for a long time.... Please use the "Insert/Edit Code samples" button when posting code on the forms.
Member
251 Points
423 Posts
Re: Access Modifier error.
May 08, 2020 12:46 AM|Markus33|LINK
I corrected error mgebhard, it was missing brackets in Controller class.. It was not apparent to me as i am following tutorial.