Static classes and methods
A C# static class becomes a Kotlin object with the same name; its static methods become functions and its properties become Kotlin properties on that object. On a non-static C# class, static members instead land in the generated Kotlin companion object alongside its instance members (see Objects and handles).
C# | Kotlin |
|---|---|
|
|
|
|
|
|
|
|
The generated object is internal: use it from anywhere else in the same Gradle module, but it never appears in your own library's generated C# API.
Calling a static method
Given a package bound as shown in Declaring dependencies, a bound static method reads like any other Kotlin function call:
Static properties
A non-static class's static properties land in its companion object, addressed through the class name itself. A property with no public setter becomes a read-only Kotlin val; a settable one becomes a var. Reading or writing either calls back into the real C# static member on every access, so a bound handle- or string-typed property follows the same rule as an instance property (see Instance members), including a nullable C# type staying nullable in Kotlin.
Overloads
Bridgeable overloads keep their shared Kotlin name; normal overload resolution picks the right one by argument type, the same as any other Kotlin overload set. An overload that isn't individually bridgeable is diagnosed on its own and doesn't hide the overloads that are; a true collision between two overloads' mapped Kotlin signatures is a generation error instead, see The bridgeable subset.