In MS Excel, it is possible to create User-defined functions in C#. Is there a way to do this also in LibreOffice Calc?
I have been looking for some information about this but I only found some documentation to do this in Python or BASIC.
Normally when people use C# with UNO (and it's not done very often), they write a C# application that connects to LibreOffice and sends commands. A UDF, on the other hand, would be the opposite — it would need to be initiated from within LibreOffice.
That means you're probably limited to the languages that LibreOffice can run from inside. According to https://wiki.documentfoundation.org/Development/Extension_Development:
Supported programming languages are Basic, Python, JavaScript, Java, BeanShell and C++.
With any of those languages, you could set up a bridge from a Basic UDF, or you could create a Calc add-in.
I can think of an alternative, which is to use a system call from a Basic UDF to call your C# program. It sounds like a mess though.
Personally, even if it were possible to cobble together a UDF with the main work done in C#, I would not do it, because that's not the preferred language for this kind of task. Why not take the time to learn a new language instead, for example, Java (similar to C#) or Python (popular with UNO nowadays)? If you are a professional programmer, learning a new language should not be something to shy away from.