Yes, there is a lot of difference in the way you develop, but not in the language.
The C# language is exactly the same on any platform. Syntax and language options you will have on any platform you develop. That’s why she’s so cool. You learn a language and can deliver products to any platform: Desktop, Store App, Mobile, Xbox, Web, Iot, Cloud, Scripts, etc...
But the mode of development changes completely from one platform to another. This is due to the very characteristics and environments of these platforms. Web is request oriented, Desktop to events, Mobile Apps there are platform specific concerns, Iot is an infinite loop, Cloud in scalability and decoupling, Xbox at a performance level that in others we do not care, Scripts then is another world. But all this with the same C#.
Trying to get closer to your question:
A function executed by a button on a desktop app can be executed by a button on a mobile app?
Simple answer: YES
Correct answer: Depends
If the function to be called has a good decoupling level - no dependencies - it can be done very smoothly.
A cool example. Vc makes a Winforms to add two numbers:
protected void btnSomar_Click(object sender, EventArgs e)
{
var primeiro = int.Parse(txtPrimeiro.Text);
var segundo = int.Parse(txtSegundo.Text);
lblResultado.Text = (primeiro + segundo);
}
Simple function, but very badly written, because it has a very high level of coupling and dependencies. To make a sum, it depends on having a object
, arguments EventArgs
, two TextBox
'es and a Label
to display the result. Migrating this to another platform is impossible. You really have to encode everything again.
But if we isolate the function of adding like this:
public interface IAdicao
{
int Somar(int primeiro, int segundo);
}
public class Adicao : IAdicao
{
public int Somar(int primeiro, int segundo)
{
return primeiro + segundo;
}
}
We can use it in our Winforms perfectly:
private readonly IAdicao _adicao = new Adicao();
protected void btnSomar_Click(object sender, EventArgs e)
{
var primeiro = int.Parse(txtPrimeiro.Text);
var segundo = int.Parse(txtSegundo.Text);
var resultado = _adicao.Soma(primeiro, segundo);
lblResultado.Text = resultado.ToString();
}
At first glance, we seem to be more complicated, but no. Because now, at the click of the button you only have some conversions to capture data from the screen and then display result. But most importantly, your business rule, the main function Soma()
is completely isolated, without any dependency, and can be ported to a mobile app, to an Iot, to the Web, which will work smoothly and without having to move around in your code.