setgraphicsAPIs is Overloaded Method match (C# Unity) - c#

Can someone help me
PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, TargetGlesGraphics.OpenGLES_2_0);
gives me this compile error :
Assets/_Developer/JEONG/Editor/BuildEditor.cs(776,18): error CS1502:
The best overloaded method match for
`UnityEditor.PlayerSettings.SetGraphicsAPIs(UnityEditor.Buil‌​dTarget,
UnityEngine.Rendering.GraphicsDeviceType[])' has some invalid
arguments
I don't know why but i follow the documentation in Unity

You should call it like that :
PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, new [] { GraphicsDeviceType.OpenGLES3 });
As per the error message, the function is expecting an array of GraphicsDeviceType. Since you want only one device type, you still have to provide an array where there is one element.
Also, the value is GraphicsDeviceType.OpenGLES3 (full name with namespace : UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 ), and not TargetGlesGraphics.Whatever .
You can see in error message that it expects a value as an array of GraphicsDeviceType, so I searched the unity doc to find this :
https://docs.unity3d.com/ScriptReference/Rendering.GraphicsDeviceType.html

Thank you sir Pac but i tried this one
PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, new [] {UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2});
and it works . Thank you also to everyone that help me. Sorry for my bad english

Related

UiPath: How to set default values to a String[] variable

I have an exception when I'm trying to launch my workflow. It cames from my array declaration where I apparently don't have the right syntax.
My syntax really looks like the one used in the UiPath tuto I follow :
The tuto syntax:
My syntax:
I don't understand how I'm supposed to write the default values for a simple array of strings...
I'm only trying to pass the values in a Write Line activity, but this shows up when compiling:
If anyone can help, I'm stuck... Thanks
--- EDIT ---
The exception message is the following one:
Message: Compilation failure:
; expected Unvalid expression terms ',' ... many times...
The full results are stored in the Data property of this exception. Correct the errors of the source, then retry the load.
I found the problem: I did not instantiate the array with new String[] at the beginning. I suppose that the tutos are written using VB and not C#, which can explain the difference.
your declaration is correct maybe you have error in the loop here is a working example

C# how to get value from specific cell datagridview

i am working on C# and trying to save my datagridview to xml.
my code as follow :
writer.WriteStartElement("NamaBarang");
writer.WriteString(dgvCart.Rows[i].Cells[1].Value.ToString);
writer.WriteEndElement();
and the error occur at
writer.WriteString(dgvCart.Rows[i].Cells[1].Value.ToString);
Error 2 The best overloaded method match for
'System.Xml.XmlWriter.WriteString(string)' has some invalid
arguments C:\Users\Eric\Desktop\C#\Gridview\Gridview\Form1.cs 59 25 Gridview
and
Error 3 Argument 1: cannot convert from 'method group' to
'string' C:\Users\Eric\Desktop\C#\Gridview\Gridview\Form1.cs 59 44 Gridview
i am previously a vb user so i am having a hard time in c#
please help.
Youve forgotten to put empty brackets () after your ToString
VB isn't bothered about this but c# is- every time you want to call a method that has no arguments, you have to put empty brackets
//this is fine in VB
Dim x as String = y.ToString
//so is this
Dim x as String = y.ToString()
//in c# we insist on brackets when calling a method
string x = y.ToString();
//no brackets means "get the value of the property"
int I = mystring.Length;
Seeing something that looks like a method name, without brackets, usually means it's a property rather than a method. It can occasionally mean that the method itself is being used as an argument - a way of passing a method around as a variable, but that's beyond the scope of what we're discussing here.. Read up on delegates if you're interested.
In short, if you want to call a method in c#, it absolutely must have brackets after the name, whether there are arguments or not
Also handy to remember that when you see the error about "is a method group" it probably means you've tried to call a method but omitted the brackets.
C# is a struggle for VB people because it's essentially way more demanding that the syntax be absolutely right- you'll get used to it though, and it does help eventually!

C# CS1502: Best Overloaded Match not finding the correct function in the docs

I am working with the C# Mono Compiler and the complier keeps giving me the CS1502 error due to not being able to find the correct function in the Docs. Specifically, I am getting problems with the Split function in the String API with the following message
The best overloaded method match for `string.Split(params char[])' has some invalid arguments
when I am trying to use the Split(String[], StringSplitOptions) function outlined on this page: https://msdn.microsoft.com/en-us/library/tabh47cf(v=vs.110).aspx
, which is found in the API documentation: https://msdn.microsoft.com/en-us/library/system.string(v=vs.110).aspx
Edit: The piece of code I am trying to write is this:
words = line.Split("\t");
I am trying to split a tab-separated String (the variable 'line') into an array of strings 'words'.
Pass the tab (\t) as a char not a string using enclosing single quotes vs. double quotes, i.e.:
words = line.Split('\t');

C# string format arguments

I know that the following syntax works
String.Format("Today is {0}, {1}", day,month);
I was just curious how this format works?
String.Format("Today is {day}, {month}", day,month);
How does C# interpret replacing number with user defined names?
String.Format("Today is {day}, {month}", day,month);
Does not work, it throws a System.FormatException.
According to the documentation the replacement fields must be in the format { index[,alignment][:formatString]} which your 2nd example does not follow.
The items in the {} must be integers beginning at 0 and match the number of variables in the second argument of .Format(...) method. Download a program, such as LinqPad, to run test scripts such as this.

Error CS1002: ; Expected -- I have a semicolon. :(

Trying to create a new instance of the "MortgageData" object.
Professor said to use:
ClassName InstanceName = New ClassName(arg1, arg2, arg3, arg4);
I Used
MortgageData somethingsomething = New MortgageData(ID,principal,apr,term);
Keep getting Error CS1002: ; Expected with the class name after new underlined in red. I'm using visual studio 2008.
Not sure what to do.
For a start, write new instead of New. C# keywords are case-sensitive, and always in lower-case!
There's already an accepted, correct answer but I would like to add a general point here:
When you get an <x> expected error don't put too much faith in it. Something is wrong there but if you don't see an obvious case of omitting whatever it's asking for start looking for other things that could have confused the parser, especially unrecognized keywords.
new is different from New is different from NEW.
Use lower-case new.

Categories